NerdConcepts Posted June 26, 2007 Share Posted June 26, 2007 I'm trying to be able to be able to select an employee and from there you enter a page that display all non-assigned inventory, so that you can assign inventory to that employee. Here is some of the code I've figured out that I will absolutely have to use. First off after selecting the employee it puts there ID (3 digit based from MySQL) and puts it into a index.php?assign=001 (002, etc) On the inventory assigning page I've got: (which is the form basically) $myid = $_GET['assign'] $query = "SELECT * FROM inventory_data WHERE assigned_id='$myid'"; $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); ?> <form action="index.php?assign=<?PHP echo $id; ?>" method="post"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { //each individual inventory lines are here. ?> <tr> <td><?PHP echo $row['inventory_id']; ?></td> <td><?PHP echo $row['Part_Description']; ?></td> <td align="center"><?PHP echo $row['Part_Number']; ?></td> <td><input type="checkbox" name="assign_select" /></td> </tr> <?PHP } <input type="hidden" name="submitted" value="TRUE" /> </form> What I have no idea how to do it get PHP to take each one, if the box is checked and run... $qUpdate = "UPDATE inventory_data SET assigned_id='$id' WHERE inventory_id='$inid'"; $rUpdate = mysql_query($qUpdate) or trigger_error("Query: $qUpdate\n<br />MySQL Error: " . mysql_error()); ...On each of them. Note: only one employee can be selected at one time so it doesn't seem like it would be that hard to do, but I can't seem to get any pointers on this one. Quote Link to comment Share on other sites More sharing options...
trq Posted June 26, 2007 Share Posted June 26, 2007 Change your checkbox to something like.... <td><input type="checkbox" name="assign_select[]" value="<?php echo $row['inventory_id']; ?>"/></td> Then... your query needs to be something like.... <?php $qUpdate = "UPDATE inventory_data SET assigned_id='{$_GET['id']}' WHERE inventory_id IN('" . implode("','",$_POST['assign_select']) . "')"; ?> Quote Link to comment Share on other sites More sharing options...
NerdConcepts Posted June 26, 2007 Author Share Posted June 26, 2007 You are such a life saver. Thank you very much. Didn't know you could do it that easily. 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.