Jump to content

Archived

This topic is now archived and is closed to further replies.

Snigs

form updation using php n mysql

Recommended Posts

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'";
$userselect2=mysql_query($userselect);
$userselect3=mysql_fetch_array($userselect2);
$x1=$userselect3['email'];
print "Your email:<input type='text' name='email' size='15' value='$x1'><p>";

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

Share this post


Link to post
Share on other sites
[code]
<?php
$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.';
}
?>[/code]

Share this post


Link to post
Share on other sites
Don't you mean mysql_fetch_assoc() if you want a hash back?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.