Jump to content

Need Help with script!


judgenules

Recommended Posts

Hello there,

 

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! :)

Link to comment
Share on other sites

Thanks for your respond. Here's the code for my function:

 

<?php

 

 

 

function get_producthistory()

{

@ $db = mysql_pconnect('localhost', 'root', '');

 

if (!$db)

{

echo 'Error, could not connect to database.';

}

mysql_select_db('brontobyte');

 

$query = "select * from inventory";

 

 

 

$result = mysql_query($query, $db);

 

return $result;

}

?>

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.