Presenting data into rows or columns is a standard action realized with a simple loop through your record set. Often the data have to be presented in a different order. This example shows a table where the results are provided into columns and rows. Each row holds a number of records from your database; if the number of columns is reached a new row will be used. If there are no more records empty cells will be created and the dynamic creation of cells and rows is ended after the last row has reached the maximum number of columns.
<?php
// this is an example query from the link page on my website, use your own data and don't forget to change the names of the results inside the table below
$query = "SELECT title, descr, link FROM linksite ORDER BY vote DESC";
$result = mysql_query($query);
$total_records = mysql_num_rows($result); // the number of records in your result set
$num_cols = 3; // the number of columns
$num_rows = ceil($total_records / $num_cols); // the number of rows
$num = 0; // don't change this value, this is the first number of each record inside a record set
echo "<table>\n";
// next the loop for the table rows
for ($rows = 0; $rows < $num_rows; $rows++) {
echo "<tr>\n";
// this is the loop for the table columns
for ($cols = 0; $cols < $num_cols; $cols++) {
if ($num < $total_records) { // show records if available (reduce by one because the first record is no. "0" (zero)
// first create variables with the values of the current record
$titel = mysql_result($result, $num, "title"); // you have to chenge the names here to fit your own sql statement
$description = mysql_result($result, $num, "descr");
$url = mysql_result($result, $num, "link");
echo "<td><b>".$titel."</b><br>".$description."<i><a href=\"".$url."\">Visit here!</a></i><td>\n";
} else { // show an empty cell
echo "<td> </td>\n";
}
$num++; // raise the number by one for the next record
}
echo "</tr>\n"; // there are no more cols in this row, close the table row tag
}
echo "</table>\n"; // end of the region = closing tag for the table element
?>
m d wrote :1823
This IMO is not a 'real' Nested repeat region
A 'real' Nested repeat region works with two or more tables and repeats the data in a 'nested' fashion by name or id.