I have a piece of code using mysql_fetch_array that does not work as I expect.
If I use the following code I get 6 items displayed to the screen as expected:
<?
$connection=mysql_connect("localhost","root","jdr0606");
mysql_select_db("phpgallery45",$connection) or die(SetSess("Openerror","Open Messages<br>".msql_errno()." : ".mysql_error()));
$sql="select distinctrow p.catalogid, p.ccode, p.cname, p.cdescription, p.cprice, p.ccategory, p.cdescurl, p.features, p.cimageurl, p.cstock, p.weight, p.mfg, p.pother1, p.pother2, p.pother3, p.subcategoryid, p.retailprice, p.specialoffer, p.category, p.buttonimage, p.cdateavailable, p.allowusertext, p.pother4, p.pother5, p.userid, p.keywords, p.template, p.extendedimage, p.extendeddesc, p.selectlist, p.level3, p.level4, p.level5, p.minimumquantity, p.supplierid, p.crossselling, p.hide, p.productmatch, p.customermatch, p.orderattachment, p.orderdownload, p.groupfordiscount, p.clanguage, p.points, p.pointstobuy, p.price2, p.price3 from products p, prodcategories cc, categories c where cc.intcatalogid=p.catalogid and cc.intcategoryid=c.categoryid and c.catdescription like '%' and hide=0 and (p.customermatch='babies' or p.customermatch is null) order by specialoffer desc,cname";
$objrs=mysql_query($sql,$connection);
$recordcount=0;
$maxrecs=10;
while ($rs=mysql_fetch_array($objrs))
{
print $rs["ccode"]."<br>";
$recordcount=$recordcount+1;
}
mysql_close($connection);
?>
however if I change the while statement to read
while ($rs=mysql_fetch_array($objrs) && $recordcount<$maxrecs)
Nothing displays!
Any ideas?
Thanks
Jeff...