Jump to content

[SOLVED] Query results and form question...


NerdConcepts

Recommended Posts

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.

Link to comment
Share on other sites

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']) . "')";

?>

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.