fantic Posted October 22, 2008 Share Posted October 22, 2008 how i can edit multiple fields like phpmyadmin data edit field? Link to comment https://forums.phpfreaks.com/topic/129555-edit-multiple-fields/ Share on other sites More sharing options...
john-formby Posted October 22, 2008 Share Posted October 22, 2008 You would echo your existing fields out to a form. When the submit button is clicked, grab the values and do an update query to overwrite the original values. Link to comment https://forums.phpfreaks.com/topic/129555-edit-multiple-fields/#findComment-671670 Share on other sites More sharing options...
john-formby Posted October 22, 2008 Share Posted October 22, 2008 Something like this: edit.php <?php $theuID = 1; if(isset($_POST['submit'])) { foreach($_POST as $key=>$value) { $$key = $value; } $sqlupdate = "UPDATE tbluser SET firstname = '$firstname', lastname = '$lastname' WHERE uID = '$uID'"; $result = mysql_query($sqlupdate); header('Location: edit.php'); } $sql = mysql_query("SELECT uID,firstname,lastname FROM tbluser WHERE uID = $theuID"); $row = mysql_fetch_array($sql); echo ' <html> <head> <title>Form</title> </head> <body> <form action="edit.php" method="post"> <input type="hidden" name="uID" value="'.$row['uID'].'" /> <input type="text" name="firstname" value="'.$row['firstname'].'" /> <input type="text" name="lastname" value="'.$row['lastname'].'" /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html>'; ?> Link to comment https://forums.phpfreaks.com/topic/129555-edit-multiple-fields/#findComment-671676 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.