philthyhoops Posted November 27, 2007 Share Posted November 27, 2007 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. Quote Link to comment Share on other sites More sharing options...
revraz Posted November 27, 2007 Share Posted November 27, 2007 If we don't see the code, how can we tell you what's wrong? Sounds like you have your submit button in the while loop instead of after it's finished. Quote Link to comment Share on other sites More sharing options...
philthyhoops Posted November 27, 2007 Author Share Posted November 27, 2007 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 Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 27, 2007 Share Posted November 27, 2007 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."; } ?> Quote Link to comment 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.