Jump to content

Please help me to get this working


baris22

Recommended Posts

Hello,

 

Please help me to get this working

 

This is my current database:

 

6c.gif

 

This is the current output of my code:

 

6a.gif

 

I am trying to get:

 

6b.gif

 

This is my current code:

 


<?  
include_once ("config/connect.php");  
$ref=$_GET['ref'];  

if (isset($_POST['ok']))   
{  
     $worker = $_POST['worker'];       
     $item_id = $_POST['item_id'];  
       
      
     for ($i=0;$i<=count($item_id);$i++) {   

     $query5 = mysql_query("UPDATE item SET worker_id = '".$worker[$i]."' WHERE item_id = '".$item_id[$i]."' ") or die(mysql_error());  
       
     }       
           
}  

?>  

<table width="100%"> 
<?  
        $query1 = "SELECT * FROM item WHERE order_reference_number='$ref' GROUP BY item_ref"; 
        $portfolio = mysql_query($query1); 
        while($row1 = mysql_fetch_array($portfolio)) {  
?> 
  <tr> 
   <td><strong><?=$row1['item_amount'];?> of <?=$row1['item_name'];?></strong></td>  
  </tr> 
  <? } ?> 
</table> 


<form action="<?=$PHP_SELF;?>" method="post">  
<table width="600" border="0" cellpadding="4" cellspacing="0" bordercolor="#CCCCCC">   

  <tr>   
    <td height="24" bgcolor="#999999"><strong>Item amount</strong></td>   
    <td height="24" bgcolor="#999999"><strong>Item name</strong></td>   
    <td height="24" bgcolor="#999999"><strong>choice a worker</strong></td>   
    <td height="24" bgcolor="#999999"><strong>chosen worker</strong></td>   
  </tr>   
  <tr>   
<?php   
$query99 = "SELECT * FROM item WHERE order_reference_number='$ref' ORDER BY item_name, item_ref";   
$portfolio = mysql_query($query99);   

while($row109 = mysql_fetch_array($portfolio)) {   
if ($itemRefLast==$row109['item_ref']) { } else {  
    if($skip){   
    $skipAmount -= 1; ?>   
    <td height="32"></td>   
    <td height="32">   
    <input name="item_id[]" type="hidden" value="<?=$row109['item_id'];?>" /></td>   
       
    <?php   
    }else{  ?>   
    <td height="32">    <?=$row109['item_amount'];?></td>   
    <td height="32">    <?=$row109['item_name'];?>   
    <input name="item_id[]" type="hidden" value="<?=$row109['item_id'];?>" /></td>   
   <?php   
          if($skipAmount == 0){   
          $skip = False;   
          }   

     if($row109['item_amount']>1){   
     $skip = True;   
     $skipAmount = $row109['item_amount']-1;   

     }   
    
}   
    ?>   
    <td>       
    <select name="worker[]" id="">   
    <option value="<?=$row109['worker_id'];?>"><?=$row109['worker_id'];?></option>   
    <option value="-">-</option>   

<?php     
$query3 = "SELECT * FROM worker";   
$portfolio1 = mysql_query($query3);   
while($row3 = mysql_fetch_array($portfolio1)) {   
?>       
<option><?php echo $row3['worker_name'];?></option>   
<?php } ?>   
</select></td>   
    <td>    <a href="g">   
      <strong><?=$row109['worker_id'];?></strong>   
       </a></td>   
  </tr><?php   
    $itemRefLast=$row109['item_ref'];  
  }   
}  
?>   
</table> 

<input type="submit" name="ok" value="Submit" onClick="return confirmPost()" />  
</form>

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.