chery Posted December 2, 2006 Share Posted December 2, 2006 How do I edit this php to show data by order of ProductID?[code]<? $sSQL="SELECT * FROM Products";$rs=mysql_query($sSQL);$rsproducts=mysql_num_rows($rs);?><? if (!($rsproducts==0)){?>[/code]I would really appreciate some imput on how to do this as I really have no idea Quote Link to comment Share on other sites More sharing options...
taith Posted December 2, 2006 Share Posted December 2, 2006 [code]<? $rs=mysql_query("SELECT * FROM Products ORDER BY ProductID");while($row=mysql_fetch_array($rs)){}?>[/code] Quote Link to comment Share on other sites More sharing options...
chery Posted December 2, 2006 Author Share Posted December 2, 2006 [quote author=taith link=topic=117103.msg477517#msg477517 date=1165065655][code]<? $rs=mysql_query("SELECT * FROM Products ORDER BY ProductID");while($row=mysql_fetch_array($rs)){}?>[/code][/quote]Unfortunately that creates an empty page showing none of the products - any ideas on what I am doing wrong.Should I be editing this part instead?[code]<table width="75%" border="1" align="center"><? while($rsProducts=mysql_fetch_array($rs)) { WriteProductRow($rsProducts[1]); } ?></table>[/code] Quote Link to comment Share on other sites More sharing options...
ataria Posted December 2, 2006 Share Posted December 2, 2006 Unfortunately that creates an empty page showing none of the products - any ideas on what I am doing wrong.You need ot make it show something :P [code]<? $rs=mysql_query("SELECT * FROM Products ORDER BY ProductID");echo "<table><tr><td></td></tr>"; // header or whatever.while($row=mysql_fetch_array($rs)){echo "<tr><td>$row['field'];</td></tr>";}?>[/code] Quote Link to comment Share on other sites More sharing options...
chery Posted December 2, 2006 Author Share Posted December 2, 2006 [quote author=ataria link=topic=117103.msg477523#msg477523 date=1165066972]Unfortunately that creates an empty page showing none of the products - any ideas on what I am doing wrong.You need ot make it show something :P [code]<? $rs=mysql_query("SELECT * FROM Products ORDER BY ProductID");echo "<table><tr><td></td></tr>"; // header or whatever.while($row=mysql_fetch_array($rs)){echo "<tr><td>$row['field'];</td></tr>";}?>[/code][/quote]That's what I was asking about: <table width="75%" border="1" align="center"><? while($rsProducts=mysql_fetch_array($rs)) { WriteProductRow($rsProducts[1]); } ?></table> Quote Link to comment Share on other sites More sharing options...
chery Posted December 2, 2006 Author Share Posted December 2, 2006 This is the entire page:[attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
ataria Posted December 2, 2006 Share Posted December 2, 2006 [quote author=chery link=topic=117103.msg477525#msg477525 date=1165067064][quote author=ataria link=topic=117103.msg477523#msg477523 date=1165066972]Unfortunately that creates an empty page showing none of the products - any ideas on what I am doing wrong.You need ot make it show something :P [code]<? $rs=mysql_query("SELECT * FROM Products ORDER BY ProductID");echo "<table><tr><td></td></tr>"; // header or whatever.while($row=mysql_fetch_array($rs)){echo "<tr><td>$row['field'];</td></tr>";}?>[/code][/quote]That's what I was asking about: <table width="75%" border="1" align="center"><? while($rsProducts=mysql_fetch_array($rs)) { WriteProductRow($rsProducts[1]); } ?></table>[/quote]It would be alot neater if you added the table in the php. so.[code]<?php$rs=mysql_query("SELECT * FROM `Products` ORDER BY `ProductID`");echo "<table width=75% border=1 align=center>"; while($rsProducts=mysql_fetch_array($rs)) { WriteProductRow($rsProducts[1]); } echo "</table>";?>[/code]you need the query in there too. :P it should work now. Quote Link to comment Share on other sites More sharing options...
chery Posted December 2, 2006 Author Share Posted December 2, 2006 BEAUTIFUL - thank you so much !!! Quote Link to comment 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.