Jump to content


form updation using php n mysql

  • Please log in to reply
2 replies to this topic

#1 Snigs

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 15 July 2006 - 06:23 PM

i have to udate the details of the user. i want that the form should show all the values which are already there in the database n then if the user wants to change any of it he can change otherwise the valuses should remain same as they were before but its not showing in the fields how do i do that so that it may show them...

my code is:

$userselect="SELECT*from b_users where username='$user'";
print "Your email:<input type='text' name='email' size='15' value='$x1'><p>";

is there some problem with this?? plz help me!!

#2 pixy

  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 15 July 2006 - 07:08 PM

$query = "SELECT email FROM b_users WHERE username='$user'";
$result = mysql_query($query);
if (mysql_num_rows($result) == 1) {
    $row = mysql_fetch_array($result, MYSQL_NUM);
    $email = $row[0];
    echo '<b>Your Email:</b> <input type="text" name="email" size="15" value="'.$email.'"><p>';
else {
    echo 'You do not have an email address saved in our database.';

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!

#3 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 15 July 2006 - 08:52 PM

Don't you mean mysql_fetch_assoc() if you want a hash back?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users