General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 12th, 2003, 04:07 PM
Mojoman's Avatar
Mojoman Mojoman is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Washington, DC
Posts: 39 Mojoman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 34 m 34 sec
Reputation Power: 6
How do I repopulate a form with data...

How do I repopulate a form with data from a mysql db?

I am building a member site with extensive user profile information. When a user needs to edit their profile, I want to send the user to a form with all their information already filled out (checkboxes, radio buttons and text fields) with data from the db.

Any suggestions?
__________________
$mybrain = "mush";
-------------------------------------------
http://www.loftsboston.com
http://www.gregdawsondesign.com

Reply With Quote
  #2  
Old May 12th, 2003, 04:36 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 7
Draw the info from the DB - set the starting values of the fields with what info is available for the user. Use conditionals for your radio buttons:
PHP Code:
if ( 'something' == 'something' )
{
      echo( 
'<input type="radio" name="somename" value="selectedValue" selected />' );
}
else
{
      echo( 
'<input type="radio" name="somename" value="selectedValue" />' );

__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
  #3  
Old May 12th, 2003, 08:41 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
heres a very quick and untested example.

(Im asuming you have already have a database connection)

PHP Code:
<?php

$query 
= @mysql_query("SELECT * FROM members WHERE id = $id");

$row = @mysql_fetch_array($query);

?>

<form>
//normal input field
<input name='' type='text' value='<?php echo $row['fieldname']; ?>'>

</form>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > How do I repopulate a form with data...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT