Jump to content

*WORKING* Updating data in my database


steves

Recommended Posts

Ok so im trying to create a form, where the information is pulled from the database and displayed in the text fields.  However, I would like to have the ability to change any data in those text fields, hit update and have it saved in the database.  Here is the code I am working on to create the page that displays the text fields, however no data is being pulled from the database and is not showing up in these text fields.  Any help is appreciated.  I know right it will not actually update that data, i will work on that after this.  I am just trying to get the data shown in the text fields of the form right now.  Thank you. 

*Made these changes below and it now works*

[code]
$search = @$_GET['search'] ;
SQL LOGIN HERE
$query = "SELECT * FROM ads WHERE ad LIKE '$search' order by ad";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){
  $title =  $row["ad"];
  $title2 = $row["ad_type"];
  $title3 = $row["resort_name"];
  $title4 = $row["resort_location"];
  $title5 = $row["week"];
  $title6 = $row["bed"];
  $title7 = $row["bath"];

  }
echo "
<form action=updated.php method=post>
Ad: <input type=text name=ad value=$title><br>
Ad Type: <input type=text name=ad_type value=$title2><br>
Resort Name: <input type=text name=resort_name value=$title3><br>
Resort Location: <input type=text name=resort_location value=$title4><br>
Week: <input type=text name=week value=$title5><br>
Bed: <input type=text name=bed value=$title6><br>
Bath: <input type=text name=bath value=$title7><br>
<input type=Submit value=Update>
</form>
";
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/26585-working-updating-data-in-my-database/
Share on other sites

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.