Forum Moderators: coopster
I have been having a problem with my script. Been working on it for days now that i dont even know what seems to be the problem. I'm trying to retrieve the data based on its category ID where when the data is retrieved, it categorizes the data on 4 different HTML tables. It works on the first table but wont work on the other three tables. Below is the script:
<?php
include('producthistory.php');
$result = get_producthistory();
?>
<div align="bottom" class="txt">Category : Facial Cream </div>
<table width="581" border="1">
<tr>
<td width="124", height="81"><div align="center" class="txt"><strong>Inventory Category ID</strong></div></td>
<td width="161"><div align="center" class="txt"><strong>Brand ID</strong></div></td>
<td width="124"><div align="center" class="txt"><strong>Quantity on Hand </strong></div></td>
<td width="145"><div align="center" class="txt"><strong>Price</strong></div></td>
<td width="124" height="81"><div align="center" class="txt"><strong>Product Name </strong></div></td>
<td width="161"><div align="center" class="txt"><strong>ReStock</strong></div></td>
<td width="124"><div align="center" class="txt"><strong>Day</strong></div></td>
</tr>
<?php
//get everything in the fields from top of table to bottom of table
$count = mysql_num_rows($result);
for($i=0; $i<$count; $i++)
{
$row = mysql_fetch_array($result);
$_GET['invCatID'] = $row['invCatID'];
if($_GET['invCatID'] == 1)
{
echo '<tr>';
echo '<td width="124">'.$row['invCatID'].'</td>';
echo '<td width="160">'.$row['brandID'].'</td>';
echo '<td width="100">'.$row['qty'].'</td>';
echo '<td width="100">'.$row['price'].'</td>';
echo '<td width="100">'.$row['productName'].'</td>';
echo '<td width="100">'.$row['reStock'].'</td>';
echo '<td width="100">'.$row['Date'].'</td>';
echo '</tr>';
}
}
?>
</table>
</br></br>
<div align="bottom" class="txt">Category : Hand Lotion </div>
<table width="581" border="1">
<tr>
<td width="124", height="81"><div align="center" class="txt"><strong>Inventory Category ID</strong></div></td>
<td width="161"><div align="center" class="txt"><strong>Brand ID</strong></div></td>
<td width="124"><div align="center" class="txt"><strong>Quantity on Hand </strong></div></td>
<td width="145"><div align="center" class="txt"><strong>Price</strong></div></td>
<td width="124" height="81"><div align="center" class="txt"><strong>Product Name </strong></div></td>
<td width="161"><div align="center" class="txt"><strong>ReStock</strong></div></td>
<td width="124"><div align="center" class="txt"><strong>Day</strong></div></td> </tr>
<?php
//get everything in the fields from top of table to bottom of
//table
$count = mysql_num_rows($result);
for($i=0; $i<$count; $i++)
{
$row = mysql_fetch_array($result);
$_GET['invCatID'] = $row['invCatID'];
if($_GET['invCatID'] == 2)
{
echo '<tr>';
echo '<td width="250">'.$row['invCatID'].'</td>';
echo '<td width="230">'.$row['brandID'].'</td>';
echo '<td width="100">'.$row['qty'].'</td>';
echo '<td width="100">'.$row['price'].'</td>';
echo '<td width="100">'.$row['productName'].'</td>';
echo '<td width="100">'.$row['reStock'].'</td>';
echo '<td width="100">'.$row['Date'].'</td>';
echo '</tr>';
}
}
?>
</table>
</br></br>
<div align="top" class="txt">Category : Wax</div>
<table width="581" border="1">
<tr>
<td width="124", height="81"><div align="center" class="txt"><strong>Inventory Category ID</strong></div></td>
<td width="161"><div align="center" class="txt"><strong>Brand ID</strong></div></td>
<td width="124"><div align="center" class="txt"><strong>Quantity on Hand </strong></div></td>
<td width="145"><div align="center" class="txt"><strong>Price</strong></div></td>
<td width="124" height="81"><div align="center" class="txt"><strong>Product Name </strong></div></td>
<td width="161"><div align="center" class="txt"><strong>ReStock</strong></div></td>
<td width="124"><div align="center" class="txt"><strong>Day</strong></div></td> </tr>
<?php
//get everything in the fields from top of table to bottom of
//table
$count = mysql_num_rows($result);
for($i=0; $i<$count3; $i++)
{
$row = mysql_fetch_array($result);
$_GET['invCatID'] = $row['invCatID'];
if($_GET['invCatID'] == 3)
{
echo '<tr>';
echo '<td width="250">'.$row['invCatID'].'</td>';
echo '<td width="230">'.$row['brandID'].'</td>';
echo '<td width="100">'.$row['qty'].'</td>';
echo '<td width="100">'.$row['price'].'</td>';
echo '<td width="100">'.$row['productName'].'</td>';
echo '<td width="100">'.$row['reStock'].'</td>';
echo '<td width="100">'.$row['Date'].'</td>';
echo '</tr>';
}
}
?>
</table>
</br> </br>
<div align="top" class="txt">Category : Other</div>
<table width="581" border="1">
<tr>
<td width="124", height="81"><div align="center" class="txt"><strong>Inventory Category ID</strong></div></td>
<td width="161"><div align="center" class="txt"><strong>Brand ID</strong></div></td>
<td width="124"><div align="center" class="txt"><strong>Quantity on Hand </strong></div></td>
<td width="145"><div align="center" class="txt"><strong>Price</strong></div></td>
<td width="124" height="81"><div align="center" class="txt"><strong>Product Name </strong></div></td>
<td width="161"><div align="center" class="txt"><strong>ReStock</strong></div></td>
<td width="124"><div align="center" class="txt"><strong>Day</strong></div></td> </tr>
<?php
//get everything in the fields from top of table to bottom of
//table
$count = mysql_num_rows($result);
for($i=0; $i<$count; $i++)
{
$row = mysql_fetch_array($result);
$_GET['invCatID'] = $row['invCatID'];
if($_GET['invCatID'] >= 4)
{
echo '<tr>';
echo '<td width="250">'.$row['invCatID'].'</td>';
echo '<td width="230">'.$row['brandID'].'</td>';
echo '<td width="100">'.$row['qty'].'</td>';
echo '<td width="100">'.$row['price'].'</td>';
echo '<td width="100">'.$row['productName'].'</td>';
echo '<td width="100">'.$row['reStock'].'</td>';
echo '<td width="100">'.$row['Date'].'</td>';
echo '</tr>';
}
}
?>
I really hope you could help me on this.
Cheers! =)
mysql_data_seek($result, 0);
this will move the pointer back to the beginning.
also, why do you asssign $_GET to another variable?
wouldn't it be simpler if you just do
if($row['invCatID'] == 1){
}