Stalingrad Posted October 9, 2012 Share Posted October 9, 2012 Hi. I am trying to create a form, well I already have and it isn't working. What I am trying to do is update multiple rows of the SAME field name with a text box displayed for each row that exists. Everything is displayed okay, but the submit button doesn't even load the page or anything.. it doesn't do anything for one thing. Even if it did, I know it wouldn't work. So my question is this... how can I update all of the displayed boxes at once with only ONE submit button? I'm thinking maybe I have something missing or something else is wrong... or maybe both! Here is my code for this piece: if($action == "stock") { $setprice = $_POST['price']; $updateprice = $_POST['updateprice']; echo "<a href=?action=edit>Edit Shop</a> | <a href=?action=view&user=$showusername>View Shop</a> | <a href=?action=stock>View Stock</a> | <a href=?action=quick>Quick Stock</a><br><br><font size=5>Stock Shop</font><br><br>"; $eq = "SELECT * FROM uitems WHERE username='$showusername' AND location='2' GROUP BY theitemid"; $ee = mysql_query($eq); while($erow = mysql_fetch_array($ee)) { $eeloc = $erow['location']; $eeid = $erow['theitemid']; $eenowid = $erow['uitemid']; $eeprice = $erow['price']; $wq = "SELECT * FROM items WHERE itemid='$eeid'"; $ww = mysql_query($wq); while($wrow = mysql_fetch_array($ww)) { $cq = mysql_query("SELECT * FROM uitems WHERE username='$showusername' AND location='2' AND theitemid='$eeid'"); $lcq = mysql_num_rows($cq); $fid = $wrow['itemid']; $fname = $wrow['name']; $fimage = $wrow['image']; $frarity = $wrow['rarity']; $fdesc = $wrow['description']; echo "<br>$fname<br><img src=/images/items/$fimage><br><br>"; ?> <input type="text" name="price" value="<?php echo "$eeprice"; ?>"><br></form> <?php } ?> <?php } ?> <br><br><input type="submit" name="updateprice" value="Update Prices"><br><br> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"></form> <?php if(isset($setprice)) { mysql_query("UPDATE uitems SET price='$setprice' WHERE username='$showusername' AND theitemid='$fid'"); echo "<font color=green>Success! Your prices have been set and updated!</font><br><br>"; } } Please, somebody help with this. I have been stuck on this page for so long now. I gave up a looong time ago, now I am going back trying to solve the issues. Thank you. Also, please keep it simple and not confusing, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/269246-how-to-create-php-dyanmic-textboxesand-submit-with-1-submit-button/ Share on other sites More sharing options...
Jessica Posted October 9, 2012 Share Posted October 9, 2012 Put the form elements (inputs) inside your form tags. Then capture the data in the $_POST array. Quote Link to comment https://forums.phpfreaks.com/topic/269246-how-to-create-php-dyanmic-textboxesand-submit-with-1-submit-button/#findComment-1383861 Share on other sites More sharing options...
Stalingrad Posted October 9, 2012 Author Share Posted October 9, 2012 I don't understand? Quote Link to comment https://forums.phpfreaks.com/topic/269246-how-to-create-php-dyanmic-textboxesand-submit-with-1-submit-button/#findComment-1383912 Share on other sites More sharing options...
cyberRobot Posted October 9, 2012 Share Posted October 9, 2012 For the form to work, the form tag needs to be wrapped around the form. Right now, they are right next to each other: <form action="<?php echo "$PHP_SELF"; ?>" method="POST"></form> Quote Link to comment https://forums.phpfreaks.com/topic/269246-how-to-create-php-dyanmic-textboxesand-submit-with-1-submit-button/#findComment-1383917 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.