Jump to content

pre populated php form from database problem


philthyhoops

Recommended Posts

so I want to populate a form from my database, edit it and then submit it back to a different table.

 

I am using a while loop to display every row entry in the database as a form field.

 

 

now when I try to add the submit button it adds one after each form field (row from the db)

(I would also like to add a form field at the top that doesnt COME from the database but will be passed to it from the form)

 

I figure that its just a problem with placement but I learn to program from google and Ive been googling all day and getting no where!

 

let me know if you need to see the code. I hope someone can help.

Link to comment
Share on other sites

yeah I crapped up all the code madly cutting and pasting the stupid button all over the place.

 

Im going to try to put the button after, I had been trying to jam it in before the while thing.

 

thanks for the quick response. If that doesn't work I GUESS I can lift up my skirt and show you my code.

 

 

emily

Link to comment
Share on other sites

This is how I do tabular updating, if you want I can show u the updating page

<?php
$table = "Table";
$q = "select * from `".$table."` Where This = 'that'";
$r = mysql_query($q) or die(mysql_error());
if(mysql_num_rows($r) >0)){	
echo "<form action=\"\" method=\"post\"><table>";
echo "<tr>";
echo "<td>FIELD NAME</td>";
//Do the same for rest of desired fields
echo "</tr>";
while($row = mysql_fetch_array($r)){
	echo "<tr>";
	echo "<td><input type=\"text\" name=\"".$row['PRIMARYKEY']."[".$row['FIELDNAME']."]\" value=\"".$row['FIELDNAME']."\" /></td>\n";
	//Do the same for rest of desired fields
	echo "</tr>";
}
echo "<tr><td><input type=\"submit\" value=\"Update\" /></td></tr></table></form>";
}
else{
echo "No Matching Records.";
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.