Re: [PHP-DB] Re: Making a new row in HTML tables
> $rows = $cols + ceil(($numdata-($cols*$cols))/$cols); Seb suggested a much easier way: $rows = ceil($numdate/$cols); -- Chris Hobbs Silver Valley Unified School District Head geek: Technology Services Coordinator webmaster: http://www.silvervalley.k12.ca.us/~chobbs/ postmaster: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Re: Making a new row in HTML tables
Hmmm. No code, but I'm guessing you'll probably want to set the width of the table to be int(sqrt(mysql_num_rows($results))), and then set up your loops to place only that amount of cells across. Then just keep going til you run out of data. So in the example of 31, you'd set the number of columns to be 5 (int(sqrt(31))), and then create a nested loop to go through your data. Hmmm. Maybe I will write some code... :) $numdata = mysql_num_rows($results); $cols = int(sqrt($numdata)); // This figures out how many $rows = $cols + ceil(($numdata-($cols*$cols))/$cols); echo ""; for ($i=1; $i<=$rows; $i++) { echo ""; for ($j=1; $j<=$cols; $j++) { echo ""; $row = mysql_fetch_array($results); echo $row['name']; echo ""; } echo ""; } echo ""; Not tested, but I bet it works :) Ian Grant wrote: > > Yeah, but if I had 31, > I'd want 6x5 and then 1 over, or something > > Hugh Bothwell <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Umm... 31 entries, 1 x 31... > > > > You might be better to choose a standard width and pad the last row with > > empty cells. > > > > "Ian Grant" <[EMAIL PROTECTED]> wrote in message > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > Hi, > > > > > > Can anyone help me with this - I have a database of people, that I want > to > > > print into an HTML table - how can I make the table wrap into an equal > > > number of rows. > > > i.e. if there are 4 entries, a 2x2 table, 6 a 2x3, 8 a 2x4, 9 a 3x3, > etc. > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- Chris Hobbs Silver Valley Unified School District Head geek: Technology Services Coordinator webmaster: http://www.silvervalley.k12.ca.us/~chobbs/ postmaster: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Re: Making a new row in HTML tables
Well it seems what you're trying to do is to set as square a table as you can. So, take your number of entries and square root it. Now round it up. Now divide the number of entries by that number and again round up. Now use these two numbers to make the table. Should be pretty straighforward... - seb -Original Message- From: Ian Grant [mailto:[EMAIL PROTECTED]] Sent: 25 July 2001 17:28 To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Making a new row in HTML tables Yeah, but if I had 31, I'd want 6x5 and then 1 over, or something Hugh Bothwell <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Umm... 31 entries, 1 x 31... > > You might be better to choose a standard width and pad the last row with > empty cells. > > "Ian Grant" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Hi, > > > > Can anyone help me with this - I have a database of people, that I want to > > print into an HTML table - how can I make the table wrap into an equal > > number of rows. > > i.e. if there are 4 entries, a 2x2 table, 6 a 2x3, 8 a 2x4, 9 a 3x3, etc. > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Re: Making a new row in HTML tables
Or 5x6 and 1 over... But if you want to minimise the number of blank fields, you could determine a max number of columns (and a minimum number of colums) that you want to display and calculate the number of blank fields for all posibilities combinations. Choose the one that minimises the number of blank fields. Robert Klinkenberg > -Oorspronkelijk bericht- > Van: Ian Grant [SMTP:[EMAIL PROTECTED]] > Verzonden:Wednesday, July 25, 2001 6:28 PM > Aan: [EMAIL PROTECTED] > Onderwerp: [PHP-DB] Re: Making a new row in HTML tables > > Yeah, but if I had 31, > I'd want 6x5 and then 1 over, or something > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Re: Making a new row in HTML tables
> -Original Message- > From: Ian Grant [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 25, 2001 11:28 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Re: Making a new row in HTML tables > > > Yeah, but if I had 31, > I'd want 6x5 and then 1 over, or something What about 16? 2x8, 4x4, or 8x2? And how would we decide which? Would 34 be 2x17, or 6x5 with 4 over? I'm with Hugh...unless you can define more clearly the rules you want this thing to operate under, the easiest thing is probably going to be to just pick a standard width and pad the last row. If you wanted to define special exceptions for total counts less than some arbitrary number (30?), that ought to be simple enough to do manually. Something like... switch ($picture count) { . . . case 4: $row_width=2; break; case 6: $row_width=3; break; case 8: $row_width=4; break; case 9: $row_width=3; break; default: $row_width=6; } should do the trick. --- Mark Roedel | "The most overlooked advantage to owning a Systems Programmer| computer is that if they foul up there's no LeTourneau University | law against whacking them around a little." Longview, Texas, USA | -- Owen Porterfield > Hugh Bothwell <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Umm... 31 entries, 1 x 31... > > > > You might be better to choose a standard width and pad the > last row with > > empty cells. > > > > "Ian Grant" <[EMAIL PROTECTED]> wrote in message > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > Hi, > > > > > > Can anyone help me with this - I have a database of > people, that I want > to > > > print into an HTML table - how can I make the table wrap > into an equal > > > number of rows. > > > i.e. if there are 4 entries, a 2x2 table, 6 a 2x3, 8 a > 2x4, 9 a 3x3, > etc. > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Making a new row in HTML tables
Yeah, but if I had 31, I'd want 6x5 and then 1 over, or something Hugh Bothwell <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Umm... 31 entries, 1 x 31... > > You might be better to choose a standard width and pad the last row with > empty cells. > > "Ian Grant" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Hi, > > > > Can anyone help me with this - I have a database of people, that I want to > > print into an HTML table - how can I make the table wrap into an equal > > number of rows. > > i.e. if there are 4 entries, a 2x2 table, 6 a 2x3, 8 a 2x4, 9 a 3x3, etc. > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Making a new row in HTML tables
Umm... 31 entries, 1 x 31... You might be better to choose a standard width and pad the last row with empty cells. "Ian Grant" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > Can anyone help me with this - I have a database of people, that I want to > print into an HTML table - how can I make the table wrap into an equal > number of rows. > i.e. if there are 4 entries, a 2x2 table, 6 a 2x3, 8 a 2x4, 9 a 3x3, etc. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]