Just an idea I came up with after turning off my computer last night 
(don't ya hate that!) - I don't know how 'dirty' or 'crude' this would 
be, but in my head it seems like it would work. Basically, what if the 
while() printed multiple tables? In each table it made 5 rows, each row 
with one cell in it, so it would then be vertical. I'm just not sure 
how to incorporate into the loop (maybe a for() loop is better for 
this?) incremental queries, so that the first loop pulls rows 1-5, the 
next query 6-10, etc. until there are no more rows. Think this might 
work?

I will still try the array method suggested by a couple of people, 
but... I haven't really ever worked with arrays.

<Pseudo code>
Do my first query:
$i=0;   //define variable
$sql = mysql_query("SELECT grad_year FROM alumni LIMIT $i, 5 GROUP BY 
grad_year");

$grad_year=""; //define variable - avoid errors

while ($row = mysql_fetch_array($sql)) {
extract($row);

if($i=="1") {
            print "<center><table width=\"10%\" border=\"0
\">\n"; //start table
                 }
 
printf("<tr><td align=\"center\"><a href=\"year.asp?year=%s\">%
s</a><br></td></tr>\n", $grad_year, $grad_year); //print links, one per 
row

if ($i=="5") {
            print "</table>\n"; //end table on $i = 5 
             }

$i+5;


$grad_year=""; //clear $grad_year
 
}
 
if ($i<5) print "</table>\n"; //end any rows with less than 5 columns

Jason Soza

----- Original Message -----
From: Justin French <[EMAIL PROTECTED]>
Date: Thursday, July 11, 2002 3:48 am
Subject: Re: [PHP] Table Making

> I hate to think what sort of a burden this would place on ther server,
> but...
> 
> You could always find out how many rows there are, then run individual
> queries for each cell of the table.  In other words, to achieve 
> this layout:
> 
> 1 4 7
> 2 5 8
> 3 6 9
> 
> You would do queries in this order:
> 
> 1
> 4
> 7
> 2
> 5
> 8
> 3
> 6
> 9
> 
> Like I said, I shudder at the thought of how much this would load 
> the server
> (especially on large rows (lots of fields) or large tables (lots 
> of rows =
> lots of queries)), but if the layout is imperative, then maybe 
> this is an
> option...
> 
> I can't see why you can't run it as
> 
> 1 2 3
> 4 5 6
> 7 8 9
> 
> 
> Cheers,
> 
> Justin
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to