homepage Welcome to WebmasterWorld Guest from 54.163.139.36
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Display Query Results In A Two Column Table?
Query Results In Two Column Table
john1000

5+ Year Member



 
Msg#: 3479199 posted 8:42 pm on Oct 16, 2007 (gmt 0)

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..

 

cameraman

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3479199 posted 8:52 pm on Oct 16, 2007 (gmt 0)

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>";

john1000

5+ Year Member



 
Msg#: 3479199 posted 8:56 pm on Oct 16, 2007 (gmt 0)

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 :)

cameraman

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3479199 posted 6:22 am on Oct 17, 2007 (gmt 0)

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!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved