wkilc Posted August 11, 2010 Share Posted August 11, 2010 Apologies... I'm a noob trying to reverse engineer code. I have a script that can retrieve values from a MySQL database (based on a session login that recognizes which user you are) and places those values into the text fields of a form, pre-populating the form. <?php mysql_connect('localhost', 'db', 'password'); mysql_select_db('users'); $id = mysql_real_escape_string($_SESSION['userid']); $select = "SELECT * FROM user_info WHERE md5(Member_No) = '$id';"; $query = mysql_query($select); if ($row = mysql_fetch_array($query)) { ?> <form> FIRST name: <input type="text" name="First" value="<?php echo stripslashes($row['First']); ?>" LAST name: <input type="text" name="Last" value="<?php echo stripslashes($row['Last']); ?>" > Birthday: <input type="text" name="Birthday" value="<?php echo stripslashes($row['Birthday']); ?>" <input type="submit" value="Submit"> </form> <?php } ?> I want to be able to connect to that same database and update ALL the values (3 in the example above) with the single click of the form button. I think I was told some time ago that it's not possible to update all the values at once? Thanks, ~Wayne Quote Link to comment Share on other sites More sharing options...
AdRock Posted August 11, 2010 Share Posted August 11, 2010 why not? UPDATE table set field='$field', field2='$field2', field3='$field3' WHERE thisfied='$thisval' make sure you protect against SQL injection $field etc would be your POST vars Quote Link to comment Share on other sites More sharing options...
wkilc Posted August 11, 2010 Author Share Posted August 11, 2010 Thank you. Problem is... I'm not sure about how to implement that into the form code listed above... can anyone please help? ~Wayne Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.