
<?php
//$bracing_num=$_POST['bracing_num'];
if ($cat=='Bracing') {
$table_name = $_SESSION['db_prefix']."_list_bracing";
$name_query = "SELECT item_name, width, depth, class FROM $table_name WHERE item_id = '".$bracing_num."'";
$name_result = mySQL_query($name_query);
$item_name = mysql_result($name_result, 0, "item_name");
$item_width = mysql_result($name_result, 0, "width");
$item_depth = mysql_result($name_result, 0, "depth");
$item_class = mysql_result($name_result, 0, "class");
}

if ($cat=='Sundries') {
$table_name = $_SESSION['db_prefix']."_list_sundries";
$name_query = "SELECT item_name, width, depth, class FROM $table_name WHERE item_id = '".$bracing_num."'";
$name_result = mySQL_query($name_query);
$item_name = mysql_result($name_result, 0, "item_name");
$item_width = mysql_result($name_result, 0, "width");
$item_depth = mysql_result($name_result, 0, "depth");
$item_class = mysql_result($name_result, 0, "class");
}

$table_name = $_SESSION['db_prefix']."_store_items";
$stock_query = "SELECT store_item_id, length, quantity FROM $table_name WHERE width = '".$item_width."' AND depth = '".$item_depth."' AND  class = '".$item_class."' AND quantity>0 ORDER BY length";
$stock_result = mySQL_query($stock_query);
$stock_num = mysql_num_rows($stock_result);


?>
<label class="label_std" style="font-size:14px;"><?php echo $item_name; ?></label><br>
<label class="label_std" style="font-size:10px;">available lengths - current stock</label>
<br>
<br>
<table width="350" border="0" style="font-size:12px;">
  <?php 
$i=0;
while ($i<$stock_num) {
 $j=0;
  	
	
	?>
  <tr>
  <?php while ($j<2) { 
    if ($i<$stock_num) {
    $length = mysql_result($stock_result, $i, "length");
	$quantity = mysql_result($stock_result, $i, "quantity");
	$store_item_id = mysql_result($stock_result, $i, "store_item_id");
    ?>
  <td width="182" valign="middle">
      <input name="store_item_id_radio" id="store_item_id_radio" type="radio" value="<?php echo $store_item_id ?>">
    <?php echo $length ?></td>
   <td width="158" valign="middle"><?php echo $quantity ?></td>
    <?php
	}
	else { ?>
    <?php
	}
	
	$i++;
	$j++;
  }
	?>
  </tr>
  <?php
  $j++;
}
  ?>
</table><br>
<label class="label_std" style="font-size:10px;">select length and enter quantity.</label>
<br>
<br>

<label class="label_std">quantity:</label>
<input type="text" name="qty_text" id="qty_text" style="width:30px;" autocomplete="off"/>

<br>
