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 Link to comment https://forums.phpfreaks.com/topic/29217-order-data-in-php-page-from-mysql/ 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] Link to comment https://forums.phpfreaks.com/topic/29217-order-data-in-php-page-from-mysql/#findComment-133938 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] Link to comment https://forums.phpfreaks.com/topic/29217-order-data-in-php-page-from-mysql/#findComment-133941 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] Link to comment https://forums.phpfreaks.com/topic/29217-order-data-in-php-page-from-mysql/#findComment-133944 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> Link to comment https://forums.phpfreaks.com/topic/29217-order-data-in-php-page-from-mysql/#findComment-133946 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] Link to comment https://forums.phpfreaks.com/topic/29217-order-data-in-php-page-from-mysql/#findComment-133948 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. Link to comment https://forums.phpfreaks.com/topic/29217-order-data-in-php-page-from-mysql/#findComment-133949 Share on other sites More sharing options...
chery Posted December 2, 2006 Author Share Posted December 2, 2006 BEAUTIFUL - thank you so much !!! Link to comment https://forums.phpfreaks.com/topic/29217-order-data-in-php-page-from-mysql/#findComment-133950 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.