Jump to content

How do i update rows in a database, using a html form?


Lee-Bartlett

Recommended Posts

this is what i have so far.

 

<?php  require_once("includes/db_connection.php");  ?>

<html>
<head></head>
<body>
  <form name="form1" method="post">
<select id="names" name="names">

<?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 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>

 

Can anyone tell me what to do next please

Looooveeeely, I just wrote you a whole script for you but this forum decided to delete it, plus leaving me with no option of going back. Just wonderful. Too lazy to start over again, sorry.

 

Anyways, check this very simple tutorial:

http://www.tizag.com/mysqlTutorial/mysqlupdate.php

 

Basically just try and access the entered values from the form by using POST and then putting them into an update query. If you have any problems with it, just ask and I'll see what I can do.

Im quite new to php so not fully with you, ive ran similar code like that before but i didnt see how that linked in with the html form. My drop down box finds my database, and for somereasson in my feilds it finds my bottom entry in my database.

 

One of my problems is, my drop down wont display my database in the feilds

 

and then the update wont work

 

hope this helps for someone who might be able to give me some insight.

 

Even looked in my php book :( no luck.

Archived

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

×
×
  • Create New...

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.