Re: putting a list of data into 3 columns?
| From: | DRN | Date: | Mon, 09 Apr 2001 22:06:57 +0000 |
| Subject: | Re: putting a list of data into 3 columns? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-47888@lists.php.net to get a copy of this message | ||
Lindsay Adams <lindsay@dingos.net> wrote in message
news:B6F54222.46F6%lindsay@dingos.net...
| This is exactly what I sent you.
| You have to realize that you can't print down one column, and then
start a
| new one.
| You have to print across, left to right before you go down.
| You have to modify the print statement to put it into a table, but
that is
| easy:
|
I have been playing about with this problem and I have come up with
the following code. I know it is not right, because it isn't working
:) but I think it is nearly what I want to do. I only want to have 3
cells in the table, with a third of the data in each.
Cheers for your help, Donald
<? $db = mysql_connect("localhost", "user","pass");
mysql_select_db("database",$db);
$query = "SELECT * FROM TYPES";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
if ($result){
$i=0;
echo "<table border=1>\n<tr>\n<td width='30%'>";
$r = mysql_fetch_array($result);
$type_name = $r["type_name"];
while ( $i < ($num_rows/3) ){
echo "$type_name[$i] <br>\n"; $i++;
}
echo "</td><td width='30%'>\n";
while ($i <= (2*$num_rows/3) ){
echo "$type_name[$i] <br>\n"; $i++;
}
echo "</td><td width='30%'>\n";
while ($i <= $num_rows ){
echo "$type_name[$i] <br>\n"; $i++;
}
echo "</tr></table>\n";
} else {
echo " sorry no data found ";
}
?>
--
Cheers, Donald :)
__________________________________________
As well as learning more,
I learn that there is even more I don't know
http://www.donaldrnoble.f2s.com
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯