I'm getting the following error for a php code insert: "mysql_num_rows(): supplied argument is not a valid MySQL result resource"
Here is my code:
global $dal;
$tblsitepages = $dal->Table("coupons");
$sql = "SELECT * FROM coupons WHERE coupon_page='".$_SESSION["pageid"]."' ORDER BY rank, couponid";
$rs = CustomQuery($sql);
if(mysql_num_rows($rs) > 0){
echo "<table width=\"1016\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">";
echo "<tr>";
for($i=0;$i<=mysql_num_rows($rs);$i=$i+1){
while($data = db_fetch_array($rs)){
$i++;
if($i%3==0){
// use the operator to find the remainder of $i / 3 (%)
// if the remainder is 0; it is a multiple of 3, so make a new row.
echo "<td width=\"336\" align=\"center\"><img src=\"http://mydomain.com/siteadmin/banners/".$data["coupon"]."\"'>http://mydomain.com/siteadmin/banners/".$data["coupon"]."\" width=\"336\" height=\"280\" border=\"0\" alt=\"Click to Print Coupon\" title=\"Click to Print Coupon\" id=\"".$data["couponid"]."\" onClick=\"printme(event)\" style=\"max-width:336px\" /></td></tr><tr>";
} else {
echo "<td width=\"336\" align=\"center\"><img src=\"http://mydomain.com/siteadmin/banners/".$data["coupon"]."\"'>http://mydomain.com/siteadmin/banners/".$data["coupon"]."\" width=\"336\" height=\"280\" border=\"0\" alt=\"Click to Print Coupon\" title=\"Click to Print Coupon\" id=\"".$data["couponid"]."\" onClick=\"printme(event)\" style=\"max-width:336px\" /></td>";
}
}
}
echo "</tr></table>";
}
This snippet calls up images from a table and display them in rows of 3.
The following original code works on a php page without issue, but I'm having difficulty converting it for use in phprunner:
$sql = mysql_query("SELECT * FROM coupons WHERE coupon_page='".$_SESSION["pageid"]."' ORDER BY rank, couponid");
if(mysql_num_rows($sql) > 0){
echo "<table width=\"1016\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">";
echo "<tr>";
for($i=0;$i<=mysql_num_rows($sql);$i=$i+1){
while($row = mysql_fetch_array($sql)){
$i++;
if($i%3==0){
// use the operator to find the remainder of $i / 3 (%)
// if the remainder is 0; it is a multiple of 3, so make a new row.
echo "<td width=\"336\" align=\"center\"><img src=\"http://mydomain.com/siteadmin/banners/".$row["coupon"]."\"'>http://mydomain.com/siteadmin/banners/".$row["coupon"]."\" width=\"336\" height=\"280\" border=\"0\" alt=\"Click to Print Coupon\" title=\"Click to Print Coupon\" id=\"".$row["couponid"]."\" onClick=\"printme(event)\" style=\"max-width:336px\" /></td></tr><tr>";
} else {
echo "<td width=\"336\" align=\"center\"><img src=\"http://mydomain.com/siteadmin/banners/".$row["coupon"]."\"'>http://mydomain.com/siteadmin/banners/".$row["coupon"]."\" width=\"336\" height=\"280\" border=\"0\" alt=\"Click to Print Coupon\" title=\"Click to Print Coupon\" id=\"".$row["couponid"]."\" onClick=\"printme(event)\" style=\"max-width:336px\" /></td>";
}
}
}
echo "</tr></table>";
}
Any assistance would be appreciated. Thank you.