ivains
10-06-2004, 07:13 PM
I'm stumped???
I got the columns going correctly. Let say I want to display the last 5 rows of information and I want it to display 3 columns per row. I get the columns; however, it displays only the very last row 5 times.
I think it has to do something with the way I'm calling up the query, but I'm not having any success.
Any suggestions would be gratefully appreciated.
Here is the query:
$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];
Here is the column code:
$b = $HowMany; // numbers to count for
$i = 0; // incrementor
$z = $NumberOfCols; // how many cols per row
echo "<div align='$TableAlign'><table width='$TableWidth' border='$TableBorder' cellspacing='0' cellpadding='3'><tr>";
while($i < $b)
{
if($i == 0 || $i == $a)
{
echo "<tr>";
$a = $a + $z; // the beginning ist always $a + cols per row or zero
$e = $a - 1; // the end ist always $a - 1 ;
if ($e > $b) // if the end ist geater then our count
{
$e = $b - 1; // we make $b - 1 and thats the end tag
}
}
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'>";
}
echo "<td width='100%'> <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 == $e)
{
echo "</tr>";
}
$i++;
}
echo "</tr></table></div>";
I got the columns going correctly. Let say I want to display the last 5 rows of information and I want it to display 3 columns per row. I get the columns; however, it displays only the very last row 5 times.
I think it has to do something with the way I'm calling up the query, but I'm not having any success.
Any suggestions would be gratefully appreciated.
Here is the query:
$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];
Here is the column code:
$b = $HowMany; // numbers to count for
$i = 0; // incrementor
$z = $NumberOfCols; // how many cols per row
echo "<div align='$TableAlign'><table width='$TableWidth' border='$TableBorder' cellspacing='0' cellpadding='3'><tr>";
while($i < $b)
{
if($i == 0 || $i == $a)
{
echo "<tr>";
$a = $a + $z; // the beginning ist always $a + cols per row or zero
$e = $a - 1; // the end ist always $a - 1 ;
if ($e > $b) // if the end ist geater then our count
{
$e = $b - 1; // we make $b - 1 and thats the end tag
}
}
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'>";
}
echo "<td width='100%'> <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 == $e)
{
echo "</tr>";
}
$i++;
}
echo "</tr></table></div>";