PHP table that allows users to input height and width [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
Hello. I have an assignment 9.2 to do and have no idea where to start.
I have made the index.php which allows the user to input the width and height of the table.
Here is the code for that:
<html>
<head>
<title>Assignment 9.2</title>
</head>
<body bgcolor="black" text="white">
<form method="post" action="table.php"
<strong>Please select an integer for the width:</strong>
<input type="text" name="width" size="10">
<br>
<strong>Please select an integer for the height:
<input type="text" name="width" size="10">
<input type="submit" value="Submit">
</form>
</body>
</html>
I do not know where to start on making the table. I do not expect to have this
done for me.. but to simply explain where to start and the php codes I need to use.
Again.. this is for 9.2 which is shown in the picture attached.

Okay, so this is a fairly simple thing to do if you understand how html tables are laid out in code...
HTML table format
The first step is to understand how tables are laid out in html...
3x2 table
For a 3 columned / 2 rowed table the code would look something like this...
Pseudo
opening table tag
opening row tag
cell tag
cell tag
cell tag
closing row tag
opening row tag
cell tag
cell tag
cell tag
closing row tag
closing table tag
HTML
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
</table>
I don't know how much you know about html but hopefully that should make sense if not there are a wide variety of resources available that can explain the tags used etc...
PHP Code
At this point we're going to skip the input of width and height (as you already have the code for that) and assume that you've captured them as follows:
$in_width = $_POST['width'];
$in_height = $_POST['height'];
So now we know what the width and height of the table is going to be we can look at how to put them together:
If you look back at the example table code above you'll see that tables are rendered one row at a time in the format:
First row first column
First row second column
First row third column
Second row first column
...and so on...
This might be more clear by looking at the numbers in your screen grab above.
Given that we know how a html table is structured we can determine that we can use two loops* (the second one embedded in the first) to produce the desired output.
(The rows will be the outer loop and the columns will be in the inner loop - see example html code above)
Pseudo code
start table
for each row {
start row
for each column {
print cell
}
end row
}
end table
*You can use any loop you're comfortable with (i.e. for or loop) they do the same thing
If you want to do this yourself, I suggest that you stop reading here. Spoiler follows...
Spoiler
Two while loops
$in_height = $_POST['height']; // Get table height
$in_width = $_POST['width']; // Get table width
$counter = 1; // Start the counter at 1
$temp_width = 0; // Set temporary variable for width(second loop)
echo "<table>"; // Print opening tag for table
while($in_height > 0){
echo "<tr>"; // Print opening tag for row
$temp_width = $in_width; // Set temp_width to width of table
while($temp_width > 0){
echo "<td>$counter</td>"; // Print cell with counter value
++$counter; // Increment counter
--$temp_width; // Decrement temp_width
}
echo "</tr>"; // Print closing tag for row
--$in_height; // Decrement height
}
echo "</table>"; // Print closing tag for table
Two for loops
Just for demonstration purposes...
$in_height = $_POST['height'];
$in_width = $_POST['width'];
$counter = 1;
$temp_width = 0;
$temp_height = 0;
echo "<table>";
for($temp_height = 0; $temp_height < $in_height; $temp_height++) {
echo "<tr>";
for($temp_width = 0; $temp_width < $in_width; $temp_width++){
echo "<td>$counter</td>";
++$counter;
}
echo "</tr>";
}
echo "</table>";
You could also mix and match loops...

Related

HTML form inside table tags changing format of table

I am creating a table to store information based on virtual companies and their stock values. I am aiming to make the table look correct while also being able to redirect the user to a separate page based on what stock they would like to buy.
I am using the following code at the moment:
PHP:
<table width = "50%" align = "center" <tr><th>Company</th><th>Price</th>
<?php
while ($row = mysqli_fetch_assoc($result))
{
$companyName = $row['companyName'];
$price = number_format($row['price'], 2);
echo "<tr><td align = 'left'>" . $companyName . "</td><td align = 'right'>" . $price . "
<form method = 'get' action = 'testing.php'><button type = 'submit' name = 'varname' value = '" . $companyName . "'>Hey</button></form>
</td></tr>";
(I currently have buttons called 'Hey' but these should essentially say 'Buy').
This will all redirect to a testing page at the moment where, based on the button that the user has pressed, a certain company name will appear. The code below works in doing that but I have one slight problem at that is with the user interface. This is what the main table looks like on the page:
Compared to what I would like it to look like when I remove the tags within the table:
As you can see, there are massive white spaces in the first picture compared to the second picture and I am aware that this is based on the tags. However, without the form tags, my program does not do what it is supposed to do.
I've researched various other posts which say that I should put the tags outside of the table. However, when trying this, I've noticed that this cannot work as the table is being displayed in a while loop.
My question is this: is there a way to fix this (i.e. by placing the tags elsewhere) or do I need to approach this problem of displaying the company the user chooses in an entirely different matter.
First major issue is the first line of your PHP:
<table width = "50%" align = "center" <tr><th>Company</th><th>Price</th>
it should be and make your percentages fit your specific needs.
<table width = "50%" align = "center">
<tr>
<th width="60%">Company</th>
<th width="40%">Price</th>
</tr>
Buttons by default are inline-block so they should align next to text unless the cell width isn't wide enough.
<form> html tag does create a lot of blank space too. And you are creating this tag multiple times by leaving it inside your loop. So:
1) exclude <form method = 'get' action = 'testing.php'> (and the respective <\form>) from your loop. This will correct your code logic and probably resolve your design questions.
If you want less space within your table you could aggregate cellspacing=0 cellpadding=0 as additional properties inside your <table> tag --> observe your openning table tag isn't closing before th and td!

Is there a another way to shorten this?

Each table is to be produced by one loop; a for loop and a while loop creating two separate tables.
Alternate rows shall be coloured using html attribute names
Every cell containing the result of the square of a number (1x1, 2x2, 3x3 etc) shall also have distinctive background using a html attribute name
Create the times table from 1 to12. (ie: 1x1 ... 12x12) - for both times tables.
Please display only the result (i.e: 1, 2, 4, 144) for the FOR loop table and display the calculation and result (i.e: 1x1=1, 2x2=4, etc) for the WHILE loop table.
<head>
<meta charset="utf-8">
<title>Multiplication Table</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1 align="center">Multiplication Table with a "forloop"</h1>
<table border ="1" align="center" width="80%">
<?php
// Create first row of table headers
$l = 12;
$c = 12;
echo '<th>X</th>';
for ($l = 1; $l <12; $l++){
echo "<th bgcolor=#d3d3d3>". $l . "</th>";
}
//set alternating table row colors
for($i = 1; $i <=$l ; $i++){
if($i%2 == 0){
echo "<tr bgcolor =#CAE3FF>";
echo "<th bgcolor =#d3d3d3>$i</th>";
}else{
echo "<tr bgcolor =#d3d3d3>";
echo "<th bgcolor =#d3d3d3>$i</th>";
}
//Set color for squared numbers
for($c = 1; $c<13; $c++){
if($i == $c){
echo "<td bgcolor = #ffffff>".$i * $c . "</td>";
}else{
echo "<td>".$i * $c ."</td>";
}
}
echo "</tr>";
}
?>
</table>
<br><br>
<h1 align="center">Multiplication Table with a "Whileloop"</h1>
<table border ="1" align="center" width="80%">
<?php
$r = 12;
$c = 12;
echo "<th>X</th>";
$r = 1;
while ( $r<= 12) {
echo "<th bgcolor = #d3d3d3>".$r. "</th>";
$r ++;
}# End of While loop
echo "</tr>";
$x = 1;
while ( $x <= $r) {
if($x % 2 == 0){
echo "<tr bgcolor =#CAE3FF>";
echo "<th bgcolor =#d3d3d3>$x</th>";
}else{
echo "<tr bgcolor =#d3d3d3>";
echo "<th bgcolor =#d3d3d3>$x</th>";
} # End of if-else 1
$y = 1;
while ( $y <=12) {
if($x == $y){
echo "<td bgcolor = #ffffff>".$x. "x" .$y."=".$x * $y . "</td>";
}else{
echo "<td>".$x. "x" .$y."=".$x * $y ."</td>";
} // End of if-else 2
$y ++;
}
$x++;
} # End of the main While loop
?>
</tr>
</table>
</body>
</html>
Since you're new, I'll do for you what I wish someone had done for me.
I've re-written your code to highlight some elements of simplification. If you'll bear with me, this will hopefully save you mountains of time and frustration. :-)
Like most beginners, you are using nested if statements because you have not yet learned to think like a professional programmer. You're mentally looping through the cells in your head and you're making decisions about them. Your code reflects that.
Lets look at what you did:
You needed to fill up this block, so we randomly put an X here. That's somewhat OK, but there's a better way.
You create a header row. also, not bad.
You're making a decision on each cell based on its content. But this is where you start to make things complicated. Not only are you needlessly printing the tr bgcolor (doesn't matter when you change the cell color), but you'r making an either or decision with an else inside a loop. That's hard to read, hard to maintain, and if you continue to develop this way, other developers will want to strangle you.
You have a secondary for loop to handle squares. This is wholly unnecessary.
But it's OK! You should see the trash I wrote when I was starting out!
Let's change the way you think to fix the code.
You probably did not start out by drawing your table on a piece of paper and coloring in your cells, but you should have. It helps you visuallize what you're about to do. I had the benefit of just running your code to see what you were doing. Quite honestly - I wasn't able to visualize it just looking at your code.
After I ran it, I saw you have three objectives:
Show odds in grey (also the default color)
Show evens in blue
Show squares in white
Now, let's think about what actually has to go on here to make this happen.
We need a header
We need to loop through 1 to 12 twice to create the table.
We need a header column so we can create that nice "x * y" lookup table
We need to change the cell color based on its value.
So, let's use a couple of rules to force us to write cleaner, better code.
Implement separation of concerns so that any given section of code is only doing one thing.
Avoid nested loops and nested if's like the plague. Only use them when necessary. (We need a nested loop to do our mutiplication, so it's ok there).
'else' is never necessary.
When making decisions, allow the decision to cascade down a decition tree until a matching condition is found.
KISS
Don't repeat yourself.
Here's the resulting code (note" I am using images because it will be easier for me to annotate the changes. The code is here in this gist for you.
The HTML
The HTML section is at the bottom of the code, and contains two simple PHP snippets to print the header and print the table.
Printing the header
Keeping with simplicity and separation of concerns, this does one thing: it prints the header. I also changed $l to $i since i is more synonymous with an index or pointer in programming.
And, I fixed a bug. You were using <12 instead of <=12 so your last column wasn't printing.
Printing the table
Again, separating out concerns, this function only wants to print the table. It doesn't care about the cells.
Here's what we're doing:
$x represents the row number.
Here, I open the row. Because each time $x increments, I should be starting a new row.
$y represents the column. I need this here only because the column matters to the row. I am NOT concerned with printing the cell in this function.
This function separates teh concern of dealing with the cell to another function aptly named print_cell.
After I have printed all the cells for the row, I should close it out so I can start a new row, or finish out the table.
Printing the cells
Again - separation of concerns: I only want to deal with printing the cell. And, thus far, I don't care about colors!
I need $x and $y, so I receive them here.
I am using printf and a format string instead of concatenation. Anytime I see an abundance of concatenation, I know I am dealing with a novice programmer who doesn't know any better. You now know better. :-)
This line determines the color, but you can see I refactored out the color logic into its own function because this function doesn't care about making color decisions - only about printing the cell.
This line is a convenience so I can deal with $n instead of $x * $y. It fills up the symbol table uselessly, but sometimes you can just splurge on a little extra memory.
This is a ternary operation, which is a basic shorthand for if...else. It doesn't violate the "else is never necessary" rule because it is limited to a single line and an "either or" condition, whereas "else" is a catch-all. It also avoids block if decisions. It's still clean code.
Here, I am printing the cell using printf.
Choosing cell colors
First, there is no need to color the <tr> because we are choosing all the cell colors, which would just override it anyway. So we don't care about <tr>'s bgcolor.
Next, Please note that the numbers in the image below do not go from top to bottom like the others 1 is at the bottom for a reason!
This function is dedicated to choosing a cell color based on its content. We want it to execute from top to bottom, and return the color for the cell as soon as it gets a match. Therefore, we put the "special" colors towards the top of the function and default, non-special ones at the bottom.
This is the default value. Cells are grey unless they are special. In order for a cell to be grey, they cannot match any of the rules above it.
Our first column for each row is actually a header. In your original code, you were creating extra code to handle this, but in reality, it's just column 0. When $y == 0, make it blue.
This is our first "special" condition for a cell color. If it's a square it's white (doesn't matter if it is even or odd).
This is our next special condition, but not as special as squares. If it's even, it's blue.
What's very important about this type of structure is that it allows the processor to return a value from a function the instant it gets a result. Nested if's, on the other hand, have to exit if after if after if after if after else before they can exit the function. This doesn't matter in an application like what you've written, but at scale when every CPU cycle counts, that's important. Plus, this is DRASTICALLY easier to read than what you wrote with all the nested statements and concatenated strings.
Conclusion
Welcome to the programming club. I hope you found this useful and helpful. Keeping your code clean and following these pracitces (as well as knowing the PSRs, and how to refactor) will go a long way in making you an excellent addition to our community. (Not just SO, but the programming community in general).
Knowing design patterns is extremely helpful too.
Remember: "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Because sometimes that violent psychopath will be you in 6 months when you're trying to figure out what the hell you did when you wrote "that code" six months ago.
Here's the re-written code
<?php
/**
* Prints the top row of the table.
* */
function print_header() {
echo '<th>X</th>';
$format = "<th bgcolor=#d3d3d3>%s</th>";
for( $i = 1; $i <=12; $i++) {
printf($format,$i);
}
}
/**
* Determines the color of the cell.
* */
function get_color($x, $y) {
//These are header rows / columns.
if($y == 0) return "#CAE3FF";
//If they are squared, x == y. This is the override.
if( $x == $y ) return "#ffffff";
//If they are even, return blue.
if( ($x * $y ) % 2 == 0 ) return "#CAE3FF";
//what's left over is either odd or weird. Return grey.
return "#d3d3d3";
}
/**
* Prints the cell
* */
function print_cell($x, $y) {
$format = "<td bgcolor = %s>%s</td>";
$color = get_color($x,$y);
$n = $x * $y;
$output = ( $n == 0 ? $x : $n);
printf($format,$color,$output);
}
/**
* Prints the rows of the table and holds the primary loop
* */
function print_table() {
for($x = 1; $x <=12; $x++) {
echo "<tr>";
for($y = 0; $y <=12; $y++) {
print_cell($x,$y);
}
echo "</tr>";
}
}
?>
<head>
<meta charset="utf-8">
<title>Multiplication Table</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1 align="center">Multiplication Table with a "forloop"</h1>
<table border ="1" align="center" width="80%">
<?php print_header() ?>
<?php print_table() ?>
</table>
</body>
</html>

i want to retrieve data from MySQL db by displaying it using table, arrange it the same way it appear in the image

<?php
$con = mysqli_connect("localhost","root","","shady");
$query = "SELECT * fROM hall1 ";
$result = mysqli_query($con,$query) or die(mysqli_error());
echo "<form action='food.php' method='post'>";
echo "<table >";
$size = 0;
while($row = mysqli_fetch_array($result))
{
$imagewidth=200;
if($size > 900)
{
echo"<tr>";
}
echo'<td width='.$td3=100 .'px > </td>' ;
echo'<td width='.$td1=200 .'px> <label><input type="radio" name="radii" value='.$row[1].' checked> <img src="'.$row['image'].'" width="200" height="200" style="margin-top:10px;"> </label></td>' ;
echo"<td width=".$td2=200 ."px> Name &nbsp: " .$row[1] ."<br> Size &nbsp &nbsp : ".$row[2] ."Person <br> Price &nbsp &nbsp: ".$row[3] ." SDG <br> See More </td>";
$size+= $imagewidth+$td1+$td2+$td3;
if($size > 900)
{
echo"<tr>";
}
}
echo"</table>";
echo "<BR><BR><BR><CENTER><input type='submit' name='radiii' value='next' width='200PX' height='200PX' ></a> </CENTER></b>";
echo "</form>";
}
?>
There are many problems with your code:
It's unclear what the variable size does. I'm willing to bet it's unnecessary
You are using deprecated code. The width attribute on HTML elements is no longer supported, and if you insist on using it, you should only enter the width in pixels without the px like so: <td width="200">. The <center> tag is also deprecated.
Your <label> tag is pretty much useless. What are you trying to achieve with it?
It's a bad practice to set the widths on all rows, just set the widths on the first row's cells. Even better, do not use any style directly on the HTML tags and using CSS rules instead.
Lastly, i believe it would be much more readable code to NOT echo HTML and instead use the following approach to "plug in" your variables from PHP into HTML code :
<? $a = "Some variable"; $b = 123; $c = "http://example.com/img/1.png"; ?>
<p><strong>My variable a: <?=$a?></p>
<p><strong>My variable b: <?=$b?></p>
<p><strong>My img: <img src="<?=$c?>"></p>
In short, wrap your PHP logic in <? and ?> (be sure to have short_open_tag = On in your PHP settings or you'll need to use the alternative opening tag <?php like you did.
The write plain old HTML without all the echo. Whenever you want to echo something you simply write a new PHP opening tag like so :
<? echo $a ?>
OR, the shorthand version
<?=$a?>
Now your real problem is about designing the page. And i think you are starting in the wrong order. I would suggest you
1- Build a design that works using some IDE like Adobe Dreamweaver or a freeware alternative. With that tool, make the design for 1 item (1 iteration of your while loop).
The next step is to see how you're gonna repeat it. You seem to want a Horizontal list that wraps around lines at a certain width. One way you would do that is that you would wrap all the list items with a div element for which you will set a fixed width. And inside you will have the code you have for each item repeated for all items. If your outer div has a width of 900px and each element consumes 300px in width and you have 9 items, you would have a 3x3 grid.
Here is a summary code of what i explained. In your PHP file you would have:
<div class="grid">
<? while($row = .... ){ ?>
<div class="item">
<!-- The code for the image, label and whatever information you want to have for each item -->
</div>
<? } ?>
</div>
And a CSS file which you would link in your PHP file, containing:
.grid {
width: 900px;
}
.item {
width: 300px;
}
If the information your are displaying come from user input you should sanitize it and have some sort of logic that breaks long text, either with CSS or PHP.
In short, you seem to be doing all the math in PHP so that you jump into a new line once the total width exceeds your desired grid width. This is a design issue and not a logic / programming issue. Therefore you should tackle this with CSS and not PHP.
I strongly suggest you either follow a video tutorial (there are plenty online) or read some documentations on HTML, CSS, JavaScript, PHP and MySQL in that order.
Here is a link to get you started: Mozilla Developer Network

Generate an HTML table with dynamic row Height

I need to print an html table with row heights sets dynamically based on some values from the database using PHP. seems that html 5 doesn't support inline height and with tags and using css instead.
My requirement is to generate an html file and then convert it into pdf using DOM pdf.
Please guide me how to set these parameters dynamically inline or using css or whether a library already available for the same purpose.
I Googled a lot, but unable find any results matching my requirement.
Also am attaching final output format
(In answer column i printed some values which is the height required for each row)
Thanks in advance
You can use inline styles:
<tr style="height: 300px;"></tr>
I am not sure if you can effectively set the height of a <tr> tag, so you might have to set the height of each <td> in the row individually. Give it a try.
Furthermore, I am not sure how you have your array of rows and columns structured, but this might shed some light on how to do it.
<?php
$array=array(array(50,'r1c1','r1c2'),array(50,'r2c1','r2c2'));
echo '<table>';
foreach($array as $row)
{
echo '<tr style="height: '.$row[0].'px;">';
echo '</tr>';
for($i=1;$i<count($row);++$1)
{
echo '<td>'.$row[$i].'</td>';
}
}
echo '</table>';
?>
If you still need help, post the exact array you wish to turn into a <table> and I will do my best to assist.
If I understand this right, your table rows can be different sizes from each other, but for each row there is a rule in database, that sets row's height, no matter what height the content of the row, right? Then you can use something like this:
<html>
<head>
<style>
<?php foreach($yourRows as $key => $row) { ?>
#row<?=$key;?>{
height: <?=$row['height']; ?>px;
}
<?php } ?>
</style>
</head>
<body>
<table>
<?php foreach($yourRows as $key => $row) { ?>
<tr id="row<?=$key; ?>">
...
</tr>
<?php } ?>
</table>
</body>
In the style tag you can replace "#row<?=$key;?>" with "#row<?=$key;?> td"
Updated
Anyway, if you want to use the inline styling, you can make it happen like that:
<html>
<body>
<table>
<?php foreach($yourRows as $row) { ?>
<tr style="height:<?=$row['height']; ?>px">
Or you can apply height to td instead of the tr...
</tr>
<?php } ?>
</table>
</body>
If you think that jQuery might work here is a suggestion. I'm not sure it works with DOMPDF but as we're dynamically creating CSS it should be fine once the DOM has loaded.
If you know exactly the heights of each row - then select them using jQuery using eq.
$(document).ready(function() {
$('table tr').eq(1).css({'height':'250'});
$('table tr').eq(3).css({'height':'450'});
});
Here is the fiddle.
That way you don't have to modify the output but you have to make the assumption the content isn't going to be higher than your fixed height.
If you need this to be more dynamic then you'll need to either associate identifiers to your rows, like a class or something like that. Or alternatively, if you have a pattern in your content is to create a regular expression that scans your content and identifies it that way - then you can apply CSS rules to these rows once matched using jQuery.
EDIT
OK so I may have slightly misunderstood if you have the height value stored in the database. It also looks as though you've determined already that you're unable to use inline styles.
Here is my next suggestion.
You're building the table from a loop so it probably looks something like this.
foreach($rows as $row) {
echo '<tr data-height="'.$row['height'].'"><td>...</td></tr>;
}
if you add data-height="'.$row['height'].'" then you have a value that we can get using jQuery's data like so.
$(document).ready(function() {
$('table tr').each(function() {
var height = $(this).data('height');
$(this).css({ 'height': height });
});
});
Here is an example fiddle with static data-height values. Let me know how you get on.

Column break in HTML/php coding issue

I have a SQL pupil's list sorted by classes and this list goes into TCPDF to create a PDF 2 columned list. My issue is that I can't find the way to break the line.
What I know is that a column can have max 59 rows. So, if the next group would not fit they should go to the next column.
The theory would be to check the actual line
$html=$html.'<tr><td width="40"> </td><td width="90"> </td><td width="50"> </td><td width="45"> </td><td width="45"> </td></tr>'; //35
while($classok = mysql_fetch_array($classquery))
{
$classes=$classok['id'];
$classnum=mysql_num_rows(mysql_query("SELECT class_id FROM pupils WHERE class_id=".$classes." AND pupils.torolve=0 and pupils.statusz=1"));
I would like here something that would shift the rows down if the next class would reach more than 59 lines. Like:
$html=$html.'<tr><td></td></tr>';
but I can't put the condition in the right way...
The problem is that the previous group randomly finishes so the next class should start the on the new page.
$headek=$headek.'<b><tr><th>D.O.B.</th><th colspan="2">';
$headek=$headek.$classok['name'].'</th><th colspan="2">';
$headek=$headek.$classok['initname'];
$sum=$sum+$classnum;
$headek=$headek.'('.$classnum.')'.'</th></tr></b>';
$html=$html.strtoupper($headek);
$pupilssql="SELECT pupils.extra_functions, pupils.name, pupils.dateofbirth, pupils.sex, YEAR(pupils.dateofbirth) AS year, MONTH(pupils.dateofbirth) AS month, DAY(pupils.dateofbirth) AS days, pupils.name, pupils.firstname, pupils.class_id FROM pupils, classes WHERE pupils.class_id=classes.id AND pupils.torolve=0 and pupils.statusz=1 AND class_id=".$classes." ORDER BY pupils.name ASC";
$pupilsquery=mysql_query($pupilssql);
while($result = mysql_fetch_array($pupilsquery))
{
etc...
Everything is working well except this column break that I can't put in code... Anyone's help would be appreciated.
They will need to be separate tables. Start a new table for each block of 59 pupils and then use CSS to float the tables so they will stack up next to each other. Or you can be lazy and put those tables inside a table and do EZ formatting (yuck).
Add a variable before your loop: $i = 0;
Iterate it at the beggining of your loop: $i++;
At the end of your loop, use if and modulus to print whatever seperator you want every 59 (or however many) lines: if($i % 59 == 0) echo '<br />';
change <br /> to whatever code you need to seperate the sections

Categories