Please help me to get this working

Discussion in 'PHP' started by baris22, Oct 21, 2009.

  1. #1
    Hello,

    Please help me to get this working

    This is my current database:

    [​IMG]

    This is the current output of my code:

    [​IMG]

    I am trying to get:

    [​IMG]

    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"> &nbsp;&nbsp; <?=$row109['item_amount'];?></td>   
        <td height="32"> &nbsp;&nbsp; <?=$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> &nbsp;&nbsp;    
        <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> &nbsp;&nbsp; <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>
    
    
    PHP:
     
    baris22, Oct 21, 2009 IP
  2. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    solved.

    thanks
     
    baris22, Oct 21, 2009 IP