Page 1 of 1

beginers php question!

Posted: Mon Mar 03, 2008 6:26 pm
by glens1234
Hi
I have the results from a database, which i am trying to display in either a table or using css etc.
At the moment it displays...

Translator Search

Name Languages Spoken
test: English,French,Spanish,German
glen simister: English,French
glen simister: English,French,Spanish,German

However i would like it to be formatted in two columns like this (without the dashes).
Name-------------------------Languages Spoken
test---------------------------English,French,Spanish,German
glen simister----------------English,French
glen simister----------------English,French,Spanish,German

here is the code...

Code: Select all

$database->setQuery($query);
$rows = $database->loadObjectList();

echo "<h2>Translator Search</h2><br />";
echo "Name Languages Spoken<br /> ";
foreach ( $rows as $row ) {
echo "$row->name: $row->languages_spoken<br />";
}
Can someone please sugguest how i can do this???
Thanks.

Re: beginers php question!

Posted: Mon Mar 03, 2008 7:20 pm
by glens1234
no worries. ive sorted it.

Code: Select all

$database->setQuery($query);
$rows = $database->loadObjectList();

echo "<h2>Translator Search</h2><br />";
echo "Name Languages Spoken<br /> ";
foreach ( $rows as $row ) {
print "<table width=400 border=1>\n";
print "<tr>\n";
print "<td>$row->name:</td><td>$row->languages_spoken</td>\n";
print "</tr>\n";
print "<table>\n";
}
The column lengths are slightly uneven but a background image should sort that out.