judgenules Posted October 26, 2007 Share Posted October 26, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/74909-need-help-with-script/ Share on other sites More sharing options...
only one Posted October 26, 2007 Share Posted October 26, 2007 Can we see your 'get_producthistory' function? Quote Link to comment https://forums.phpfreaks.com/topic/74909-need-help-with-script/#findComment-378773 Share on other sites More sharing options...
judgenules Posted October 26, 2007 Author Share Posted October 26, 2007 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; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/74909-need-help-with-script/#findComment-378793 Share on other sites More sharing options...
Lukela Posted October 26, 2007 Share Posted October 26, 2007 Whats the error that displays when executing? Quote Link to comment https://forums.phpfreaks.com/topic/74909-need-help-with-script/#findComment-378799 Share on other sites More sharing options...
judgenules Posted October 26, 2007 Author Share Posted October 26, 2007 It doesn't give any errors, it just shows a blank row on table 2, 3 and 4 but not on table 1. Quote Link to comment https://forums.phpfreaks.com/topic/74909-need-help-with-script/#findComment-378802 Share on other sites More sharing options...
sasa Posted October 26, 2007 Share Posted October 26, 2007 insert line mysql_data_seek($result,0); befor table 8, 3 and 4 Quote Link to comment https://forums.phpfreaks.com/topic/74909-need-help-with-script/#findComment-378853 Share on other sites More sharing options...
judgenules Posted October 26, 2007 Author Share Posted October 26, 2007 It still doesn't work. u have any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/74909-need-help-with-script/#findComment-378876 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.