Stalingrad Posted October 8, 2012 Share Posted October 8, 2012 Hi! I am trying to create this form, it might be dynamic? I want to allow my users to be able to select the images they want, and then click submit. They don't have to select all of them, either. It will be up to them. I have the code showing the images being grabbed from the database, then being displayed; however I have no idea how to create this form. I'm pretty sure, again, it is a dynamic form. How should I do this? I want a check box under each image, and just one submit button at the end. I'm kind of confused here as of how this would work... and help is appreciated, thank you! Here is the part of the code I am using for this: if($action == "quick") { 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>Quick Stock</font><br><br>"; $sen = "4"; echo "<table border=0>"; echo "<tr>"; $qsq = "SELECT * FROM uitems WHERE username='$showusername'"; $qs = mysql_query($qsq); while($qwe = mysql_fetch_array($qs)) { $oid = $qwe['uitemid']; $otid = $qwe['theitemid']; $oloc = $qwe['location']; $opri = $qwe['price']; $iqwe = "SELECT * FROM items WHERE itemid='$otid'"; $rwe = mysql_query($iqwe); while($yop = mysql_fetch_array($rwe)) { $irma = $yop['image']; $nima = $yop['name']; $ida = $yop['itemid']; $disa = $yop['description']; $rira = $yop['rarity']; echo "<td><center><img src=images/items/$irma><br>$nima</center></td>"; $sen--; if(!$sen) { echo "</tr><tr>"; $sen=4; } } } Thanks again for nay help in advance. Quote Link to comment https://forums.phpfreaks.com/topic/269243-forms-1-checkbox-per-row-with-1-submit-button/ Share on other sites More sharing options...
requinix Posted October 8, 2012 Share Posted October 8, 2012 (edited) Name each checkbox like <input type="checkbox" name="select[]" value="id of the image" /> Select Then array_filter((array)$_POST["select"], "ctype_digit") will be an array of all the IDs selected. The magic is the [] in the name which tells PHP to create an array instead of just a single string value. Don't forget to check isset($_POST["select"]) first: if none were checked (or the form wasn't submitted) then $_POST["select"] will not exist at all. Edited October 8, 2012 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/269243-forms-1-checkbox-per-row-with-1-submit-button/#findComment-1383845 Share on other sites More sharing options...
Stalingrad Posted October 9, 2012 Author Share Posted October 9, 2012 Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/269243-forms-1-checkbox-per-row-with-1-submit-button/#findComment-1383859 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.