Hi Everyone,
Im writing a module to display the last property entries from the db. I got it to work vertically with no problem, but when I change the parameter to display it horizontal I get the following:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in X:wampserverwwwXXXXXmodulesmod_ea_latestpic.php on line 114.
This is Line 114:
[CODE]$count = mysql_num_rows($query);
It also only displays the last entry only, no matter if I have it set to display 2, 3, 4 etc.
This is my entire code:
[code=php]
# Module Parameter Settings
$HowMany = @$params->HowMany ? $params->HowMany : ‘5’;
$Alignment = @$params->Alignment ? $params->Alignment : ‘1’;
$LineColor1 = @$params->LineColor1 ? $params->LineColor1 : ‘#FFFFFF’;
$LineColor2 = @$params->LineColor2 ? $params->LineColor2 : ‘#EBE7E7’;
$NumberOfCols = @$params->NumberOfCols ? $params->NumberOfCols : ‘4’;
$ColumnWidth = @$params->ColumnWidth ? $params->ColumnWidth : ‘25%’;
### DONT EDIT BELOW THIS LINE #################################################
# Set path to thumbnails
$picturepath = $mosConfig_live_site.$ea_picpath.”/”;
$query=”SELECT
t1.id, t1.obj_cat, t1.obj_title, t1.obj_publish,
t1.obj_pub_start, t1.obj_pub_stop, t2.img_id, t2.obj_img1, t3.cat_id, t3.cat_name
FROM
#__estateagent_object AS t1
LEFT JOIN #__estateagent_images AS t2 ON t2.img_id=t1.id
LEFT JOIN #__estateagent_category AS t3 ON t3.cat_id=t1.obj_cat
WHERE
(
(
(
(
t1.obj_pub_start >= ‘0000-00-00 00:00:00’
AND
t1.obj_pub_start <= ‘$todate 23:59:59’
)
AND
(
t1.obj_pub_stop <= ‘$todate 23:59:59’
AND
t1.obj_pub_stop >= ‘$todate 00:00:00’
)
)
OR
(
(
t1.obj_pub_start >= ‘0000-00-00 00:00:00’
AND
t1.obj_pub_start <= ‘$todate 23:59:59’
)
AND
t1.obj_pub_stop >= ‘$todate 23:59:59’
)
OR
(
t1.obj_pub_stop >= ‘$todate 00:00:00’
AND
t1.obj_pub_stop <= ‘$todate 23:59:59’
)
OR
(
t1.obj_pub_start = ‘0000-00-00 00:00:00’
AND
t1.obj_pub_stop = ‘0000-00-00 00:00:00′
)
)
AND
t1.obj_publish=’1’
)
ORDER BY t1.id DESC LIMIT $HowMany”;
# Query the database
$database->setQuery( $query );
$rows = $database->loadObjectList();
$row=$rows[0];
# Put the output on screen for Vertical Alignment
if ($Alignment == ‘1’) {
foreach($rows as $row) {
$content .= “<center><a href=’index.php?option=com_estateagent&Itemid=0&func=showObject&objid=$row->id’><b>$row->cat_name</b><br>”;
if($id != $row->img_id) {
$sm_pic = “<img src='”.$picturepath.”thmb_”.$row->obj_img1.”‘ border=’0′ alt=’$row->obj_title’>”;
} else {
$sm_pic = “<img src='”. $mosConfig_live_site.”/components/com_estateagent/obj_pictures/nopic.png’ border=’0′ alt=’$row->obj_title’>”;
}
$content .= “$sm_pic”;
$content .= “<br><font size=’1′>$row->obj_title</font></a></center><br>”;
}
}
# Put the output on screen for Horizontal Alignment
if ($Alignment == ‘2’) {
$content .=”<div align=’center’><table width=’100%’ border=’1′ cellspacing=’2′ cellpadding=’0′><tr>”;
$count = mysql_num_rows($query);
for($i=0; $i<$count; $i++)
{
$r = mysql_fetch_array($query);
$id=$r[“id”];
$obj_cat=$r[“obj_cat”];
$obj_title=$r[“obj_title”];
$obj_publish=$r[“obj_publish”];
$obj_pub_start=$r[“obj_pub_start”];
$obj_pub_stop=$r[“obj_pub_stop”];
$img_id=$r[“img_id”];
$obj_img1=$r[“obj_img1”];
$cat_id=$r[“cat_id”];
$cat_name=$r[“cat_name”];
}
if($id != $row->img_id) {
$sm_pic = “<img src='”.$picturepath.”thmb_”.$row->obj_img1.”‘ border=’0′ alt=’$row->obj_title’>”;
} else {
$sm_pic = “<img src='”. $mosConfig_live_site.”/components/com_estateagent/obj_pictures/nopic.png’ border=’0′ alt=’$row->obj_title’>”;
}
$content .=”<td
align=’center’ width=’$ColumnWidth’><a
href=’index.php?option=com_estateagent&Itemid=0&func=showObject&objid=$row->id’><b>$row->cat_name</b><br>$sm_pic<br><font
size=’1′>$row->obj_title</font></a></td>”;
if ($i%3==2);
$content .=”</tr></table></div>”;
}
Any help would be gratefully appreciated.