NerdConcepts Posted June 23, 2007 Share Posted June 23, 2007 I've been brain storming this for a while and can't come up with a way to do this. I've got a list of employees in a database I've got a list of inventory in a database What I am trying to do it show a drop down box with all the employees (done this, no big deal). Once you select someone it shows all available inventory and a check box beside each one. Got this working but not sure if it's right, just using a query and a while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { code to display a table row for each query result. Basically I cannot find any code for an example of how to allow me to select a check box beside any inventory I want to assign to an employee and then when I hit "assign" (better known as a submit button) it to change Inven_Assign in the database to whatever employee I have select. Employees have them assigned a 3 digit number from SQL which is what ends up going into the database under Inven_Assign table. I've got almost 10 PHP books and none of them have this. Is it not possible? Quote Link to comment https://forums.phpfreaks.com/topic/56810-multi-query-return-then-modify/ Share on other sites More sharing options...
cooldude832 Posted June 23, 2007 Share Posted June 23, 2007 first off slow down your post is very difficult to understand. Secondly please provide code if you wish to be helped. Quote Link to comment https://forums.phpfreaks.com/topic/56810-multi-query-return-then-modify/#findComment-280685 Share on other sites More sharing options...
pocobueno1388 Posted June 23, 2007 Share Posted June 23, 2007 Could you post the code you have? It would be easier to see the setup you have, and also we could show you how to do it using your current code, instead of typing some example code then you having to figure out how to apply it to your code. Quote Link to comment https://forums.phpfreaks.com/topic/56810-multi-query-return-then-modify/#findComment-280689 Share on other sites More sharing options...
NerdConcepts Posted June 23, 2007 Author Share Posted June 23, 2007 Here is what I have. first you enter inventory.php?select that is where you select the person you want to add inventory to after that it takes you to the ?assign part which, as of right now, you have to assign using individuals forms with buttons for each piece of inventory. if (isset($_SESSION['user_type']) && isset($_GET['assign'])) { $id = $_GET['assign']; if (isset($_POST['subAssign'])) { $inid = $_POST['inventory_id']; $qUpdate = "UPDATE dn_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()); } $query = "SELECT * FROM dn_inventory_data WHERE assigned_id='' ORDER BY Part_Number ASC"; $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); ?> <center> <table border="0" cellpadding="0" cellspacing="0" align="center" width="100%"><tr><td> <fieldset> <legend>Assign Inventory</legend> <table border="0" cellspacing="0" cellpadding="0" height="300" width="100%"> <tr valign="top"><td> <table border="0" cellspacing="0" cellpadding="2" width="100%"> <tr class="title"> <form action="inventory.php?assign" method="post"> <td>Part Description</td> <td align="center">Waybill</td> <td align="center">Part Number</td> <td align="center">R00</td> <td align="center">S00</td> <td align="center">Serial Number</td> <td> </td> <input type="hidden" name="inventory_id" value="<?PHP echo $row['inventory_id']; ?>" /> <input type="hidden" name="subAssign" value="TRUE" /> </form> </tr> <?PHP $bg = '#f4f3f2'; // Set background colour. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $bg = ($bg=='#f4f3f2' ? '#f0efed' : '#f4f3f2'); // Switch background colour. ?> <form action="inventory.php?assign=<?PHP echo $id; ?>" method="post"> <tr class="Text" bgcolor="<?PHP echo $bg; ?>"> <td><?PHP echo $row['Part_Description']; ?></td> <td align="center"><?PHP echo $row['Waybill']; ?></td> <td align="center"><?PHP echo $row['Part_Number']; ?></td> <td align="center"><?PHP echo $row['R00']; ?></td> <td align="center"><?PHP echo $row['S00']; ?></td> <td align="center"><?PHP echo $row['Serial_Number']; ?></td> <td align="right"> <?PHP if ($row['assigned_id'] == '$id') { ?><input type="submit" value="Un-Assign" name="submit" class="regButton" /><?PHP } else { ?><input type="submit" value="Assign" name="submit" class="regButton" /><?PHP } ?> </td> </tr> <input type="hidden" name="inventory_id" value="<?PHP echo $row['inventory_id']; ?>" /> <input type="hidden" name="subAssign" value="TRUE" /> </form> <?PHP } ?> </table> </td></tr></table> </fieldset> </td></tr></table> <?PHP } elseif (isset($_SESSION['user_type']) && isset($_GET['select'])) { if ($_SESSION['user_type'] != 'Admin') { echo 'NO ADMIN<Br />'; } ?> <center> <table border="0" cellpadding="0" cellspacing="0" align="center" width="100%"><tr><td> <fieldset> <legend>Select Staff Member to Assign Inventory</legend> <table border="0" cellspacing="0" cellpadding="0" height="300" width="50%"> <tr valign="top"><td> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr class="title"> <td>User ID</td> <td>User Name</td> <td> </td> </tr> <?PHP $query = "SELECT user_id,user_name FROM users ORDER BY user_id ASC"; $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); $bg = '#f4f3f2'; // Set background colour. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $bg = ($bg=='#f4f3f2' ? '#f0efed' : '#f4f3f2'); // Switch background colour. ?> <tr class="Text" bgcolor="<?PHP echo $bg; ?>"> <td><?PHP echo $row['user_id']; ?></td> <td><?PHP echo $row['user_name']; ?></td> <td align="right"><a href="inventory.php?assign=<?PHP echo $row['user_id']; ?>">Assign</a></td> </tr> <?PHP } ?> </table></td></tr></table> </fieldset> </td></tr></table> </center> <?PHP } Quote Link to comment https://forums.phpfreaks.com/topic/56810-multi-query-return-then-modify/#findComment-280744 Share on other sites More sharing options...
NerdConcepts Posted June 23, 2007 Author Share Posted June 23, 2007 I still cannot figure this out. Tried to look up a code example or anything close to what I am doing, just don't know what commands are used so it's being hard for me to find a code reference or examples anywhere out there. I know this should be simple, or at least not to complicated. Seem it once or twice on other sites written in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/56810-multi-query-return-then-modify/#findComment-281037 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.