I have ran into an issue trying to use a series of checkboxes to select multiple pieces of equipment from a list so that a user can then "checkout" the items.
Here is my first page that submits the data
<div class="list"><form action="remove.php" enctype="multipart/form-data"
name="form" id="form">
<input type="submit" style="color: white; background: none repeat scroll 0% 0%
black; font-size: 21px; padding-bottom: 30px; position: fixed; height: 30px;
right: 0px; margin-right: 1px;"
value="Checkout" />
<table cellpadding="0" cellspacing="0" border="0" id="table">
<thead>
<tr>
<th>Select</th>
<th>Equipment Number</th>
<th>Equipment</th>
</tr></thead>
<tbody>
<? $sql = "SELECT * FROM equipment";
$result = mysql_query($sql);
while ($rows = mysql_fetch_array($result)) {
if ($rows['equip_avail'] == "1") {
?>
<tr>
<td width="5%"><input type="checkbox" name="equip_id" value="<?php echo
$rows['equip_id']; ?>" /></td>
<td width="13%"><?php echo $rows['equip_num'];?></td>
<td width="20%"><?php echo $rows['equipment']; ?></td>
</tr>
<?php
}
}
echo '</tbody></table></form></div>';
}
?>
And here is the page that then takes the data from the url, and posts it to confirm, I need this page to be able to take multiple "equip_id" from the url (or another workaround I am currently unaware of) and update the information for the correct "user_id". I can get multiple to appear in the URL but only the last one is grabbed.
$id = $_SESSION['id'];
$equip_id =$_GET['equip_id'];
$sql = mysql_query("SELECT * FROM equipment WHERE equip_id='$equip_id'");
while($row = mysql_fetch_array($sql)){
$equip_id = $row['equip_id'];
$equipment = $row["equipment"];
$equip_num = $row["equip_num"];
$equip_avail = $row["equip_avail"];
$user_id= $row['user_id'];
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$user_id = $_POST['user_id'];
$equip_avail = $_POST['equip_avail'];
$sql = mysql_query("UPDATE equipment SET user_id='$user_id',
equip_avail='$equip_avail' WHERE equip_id='$equip_id'");
header("Location: equipment_checkout.php");
exit();
} // close if post
?>
This is the HTML
<table height="225px">
<form action="<? echo 'remove.php?equip_id='.$equip_id.' '?>"
method="post" enctype="multipart/form-data" name="form" id="form">
<td width="423" valign="top"><h2>Equipment: <?php echo $equipment?></h2>
<h2>Equipment Number: <?php echo $equip_num?></h2>
<input name="equip_avail" type="hidden" id="equip_avail" value="0" size="30"
maxlength="24" />
<?if(($_SESSION['id'] !=='0') && ($uaccounttype !== 'e') &&
($uaccounttype !== 'd')){?>
<input name="user_id" type="hidden" id="user_id" value="<? echo $_SESSION['id']
?>" size="30" maxlength="64" />
</tr><?} else {
$sql="SELECT * FROM members WHERE accounttype IN ('b', 'c', 'e')";
$result = mysql_query($sql);
?>
<h2>Select Employee: <select name="user_id" id="user_id">
<? $count = 1;
while($rows = mysql_fetch_array($result)){
if($count == 1){?>
<option value="<?echo $rows['id'];?>">
<? echo $rows['firstname']. " ". $rows['lastname'] ;}} ?></option>
</select></h2>
<?}?>
<input name="Submit" type="submit" value="Check Out"/>
</br>
</td>
</form>
</table>
</div>
What I need this last part to do is for every "equip_id" selected from the first page, to be displayed here and then the database to be updated with the correct "user_id" for each of the equipment selected. Like I said, I can get one to update at a time, I just need to make it so that a large amount can be edited.
**NOTE: I know that this is not a secure way to send data, if any advice on how to so this more securely, I would love it. THANK YOU!!!!