Welcome to WebmasterWorld Guest from 23.23.53.177

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Display Query Results In A Two Column Table?

Query Results In Two Column Table

   
8:42 pm on Oct 16, 2007 (gmt 0)

10+ Year Member



I know this is asked before and i tried a few things but i do fail in getting it to work..

the code :

global $database;
$query= "SELECT * FROM #__ew_cover WHERE active = 1";

$database->setQuery( $query );
$rows = $database->loadObjectList();
if ($database->getErrorNum()) {
echo $database->stderr();
return false;
}
$count = count( $rows );
$randItems = array_rand($rows, count($rows));
$row = &$rows[$randItems[0]];
$dtext = html_entity_decode($row->text);

$row2 = &$rows[$randItems[1]];
$row2->id = $row2->cid;
$dname= $row->name;
$dname2= $row2->name;
$dtext2= html_entity_decode($row2->text);

echo "<table width=100%><tr></tr><tr>";
echo "<tr><th width=45% valign=top>$dname:</th><th width=45% valign=top>$dname2:</th></tr>";
echo "<tr><td valign=top><img src=\"$dtext\"></td><td valign=top><img src=\"dtext2\"></td></tr>";
echo "<tr></tr><tr></tr></table>";

For some reason it shows the images just in 1 column,while it should do that in 2 columns.
The title shows ok, seperated left and right (2 column)...
As you see also,the code is based on random image,but i dont wanna use it anymore.
so what i want is that the results of the simple query shows the results in a 2 column table.
Can anyone help me to get this working..

Thank you..

8:52 pm on Oct 16, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Assuming the rest of it works (I just scanned it for errors, not logic), you're missing a dollar sign.
change:
echo "<tr><td valign=top><img src=\"$dtext\"></td><td valign=top><img src=\"dtext2\"></td></tr>";
to
echo "<tr><td valign=top><img src=\"$dtext\"></td><td valign=top><img src=\"$dtext2\"></td></tr>";
8:56 pm on Oct 16, 2007 (gmt 0)

10+ Year Member



cameraman..
man i feel stupid...
how could i have missed that....
i cant believe this...

thanks,the other show now...
thanks for waking me up :)

6:22 am on Oct 17, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



LOL no reason to feel stupid, it's always the little things that hang you up - I've done the same sort of thing myself so many times that that's what I look for first!