Jump to content


PHP Fill a Form from a Database: Newbie question please help

  • Please log in to reply
1 reply to this topic

#1 newbiehacker

  • Members
  • PipPip
  • Member
  • 11 posts

Posted 02 August 2006 - 10:24 PM

HI how can you fill a form from a database? I have textboxes and need to pull the data from the database into the textboxes. I know how to create the querys but cant seem to figure out how to get the data into those boxes. PLEASE HELP

#2 legohead6

  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 02 August 2006 - 10:27 PM

heres a simple editing datascript! just replace the wrong info and add remve boxes... Edit: MAde extremely basic

EDIT:2 added a } before the form
@mysql_select_db($database) or die( "Unable to select database");
$query2="SELECT * FROM listings WHERE id='$id'";

$result2 = mysql_query($query2) or die ("Error in query: $query2. ".mysql_error());
while($row = mysql_fetch_row($result2)){

//All the field you want to show in text boxes
//the form
echo "<form method=POST enctype='multipart/form-data'>Title<input type=text name=title value=$title><br><br>Price<input type=test name=price value=$price><br><br>$pic Description<br><textarea name=des>$des</textarea><br><input type=submit name=submit value=Update!></form>";

//the acculy editing of database

//the rows in the databse are case sensitive!

$query="UPDATE listings SET title='$tit', price='$pri', description='$desc' WHERE id='$lid'";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
echo "<p><b>Listing Successfully Updated!</b></p>";

"Syntax error" .. WHERE THE **** IS IT?!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users