Jump to content

Forms: 1 Checkbox Per Row, With 1 Submit Button?


Stalingrad

Recommended Posts

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. :)

Link to comment
Share on other sites

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 by requinix
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.