Lee-Bartlett Posted October 2, 2008 Share Posted October 2, 2008 Yep im still unsure on how you do this, i have followed x ammount of tutorial to try do this and i cant find it. Can you do it with strict php ? or do you need java along side it? All i need to do is this. I wanna search my user, say in a drop down box, then have the feilds which will update each row if the information is changed in the text feild. Can anyone help me please, been looking for good part of a week Quote Link to comment https://forums.phpfreaks.com/topic/126771-how-do-you-update-a-database-using-html-form/ Share on other sites More sharing options...
Zhadus Posted October 2, 2008 Share Posted October 2, 2008 If you're talking about dynamically filling in the fields once the user is selected in a drop down box, it will need to be javascript. If you'll "submit" the information and load up a new page, PHP will do just fine. If you can answer that I should be able to direct you to the correct place/tutorial. Quote Link to comment https://forums.phpfreaks.com/topic/126771-how-do-you-update-a-database-using-html-form/#findComment-655667 Share on other sites More sharing options...
Lee-Bartlett Posted October 2, 2008 Author Share Posted October 2, 2008 Ye i will be submiting the information then re-directing the user (only has to be very basic since im a learner) I would like to update the user by a id feild if possible. php version will be great Quote Link to comment https://forums.phpfreaks.com/topic/126771-how-do-you-update-a-database-using-html-form/#findComment-655670 Share on other sites More sharing options...
Zhadus Posted October 2, 2008 Share Posted October 2, 2008 This site is awesome. If you've already got a database set up. Items 4 and 7 should be what you need. Â http://www.php-mysql-tutorial.com/ Quote Link to comment https://forums.phpfreaks.com/topic/126771-how-do-you-update-a-database-using-html-form/#findComment-655676 Share on other sites More sharing options...
Lee-Bartlett Posted October 2, 2008 Author Share Posted October 2, 2008 Ye i have looked at this site before, thats where i got the insert using html form but it doesnt show you how to update it using a html form. Thanks for trying tho, really appreciate it  i would like somthing like this, but in a html form  mysql_select_db("roberts_work", $connect); mysql_query("UPDATE tblbasicform SET location = 'Harlow' WHERE name = 'chris' AND email = 'chris@chris.com'"); mysql_close($connect);   Quote Link to comment https://forums.phpfreaks.com/topic/126771-how-do-you-update-a-database-using-html-form/#findComment-655680 Share on other sites More sharing options...
Zhadus Posted October 2, 2008 Share Posted October 2, 2008 I see where you're having the issue. Okay then what you need is this tutorial:  http://www.tizag.com/phpT/forms.php  Basically you do a standard HTML form with the target into a PHP page. That PHP page loads the variables that you "POSTED" with the form, and then you use PHP to update the MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/126771-how-do-you-update-a-database-using-html-form/#findComment-655688 Share on other sites More sharing options...
Lee-Bartlett Posted October 2, 2008 Author Share Posted October 2, 2008 Not completly sure how to adapt my current form to that, currently i have  <?php require_once("includes/db_connection.php"); ?> <html> <head></head> <body>  <form name="form1" method="post" action="process.php"> <select id="names" name="name"> <?php  $nameQry = "SELECT * FROM tblbasicform";    $result = mysql_query($nameQry) or die(mysql_error());   while($row = mysql_fetch_array($result)){ echo "<option>". $row['name'];     echo "</option>"; $name = $row['name'];   $email = $row['email'];   $location = $row['location'];   $id = $row['id'];  } ?> </select> <br>  Input First Name: <input name="name" type="text" name="firstname" value="<? echo $name ?>" /><br />  Input Email: <input type="text" name="email" value="<? echo $email ?>" /><br />  Input Location: <input type="text" name="location" value="<? echo $location?>" /><br />  Input ID Number: <input type="text" name="id" value="<? echo $id?>" /><br /> <input type="submit" name="submit" value="Update Data" /> </form> </body> </html>  not sure what needs to go into the process.php bit Quote Link to comment https://forums.phpfreaks.com/topic/126771-how-do-you-update-a-database-using-html-form/#findComment-655705 Share on other sites More sharing options...
Zhadus Posted October 2, 2008 Share Posted October 2, 2008 process.php will contain variables that draw the posted variables, e.g.: Â <?php $firstname = $_POST['firstname']; $email = $_POST['email']; $location = $_POST['location']; $id = $_POST['id']; ?> Â And after getting the variables like that, you use the variables ($firstname, $email, etc.) to update using the code you posted for MySQL. For instance, if you were going to just update a location: Â mysql_select_db("roberts_work", $connect); mysql_query("UPDATE tblbasicform SET location = '" . $location . "' WHERE name = '". $firstname . "' AND email = '" . $email . "'"); mysql_close($connect); Â Understand it now? Quote Link to comment https://forums.phpfreaks.com/topic/126771-how-do-you-update-a-database-using-html-form/#findComment-655722 Share on other sites More sharing options...
Lee-Bartlett Posted October 2, 2008 Author Share Posted October 2, 2008 Kind of, ill mess about with it a little and see how it hoes. ty Quote Link to comment https://forums.phpfreaks.com/topic/126771-how-do-you-update-a-database-using-html-form/#findComment-655725 Share on other sites More sharing options...
Zhadus Posted October 2, 2008 Share Posted October 2, 2008 That's probably the best route, some trial and error. It's actually very simple once you know the process and I'm sure you'll take off from there. If you have any other issues or specific questions, feel free to post or contact me directly and I'll do what I can. Quote Link to comment https://forums.phpfreaks.com/topic/126771-how-do-you-update-a-database-using-html-form/#findComment-655728 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.