ChocolateLover
Programmer
Can anyone help please.
I'd like to create a table to display information from a query. The table has 4 columns, so the 5th record should be displayed in the 1st column of the 2nd row, the 9th record in the 1st column of the 3rd row, etc.
This is the code
The problem is that it's not displaying every 5th record as I'm skipping it by using $row_retailer_list = mysql_fetch_assoc($retailer_list) twice when I start a new row. Is there a function that moves the internal recordset pointer backwards? Or can someone suggest a better way of displaying the table?
Any help would be greatly appreciated.
I'd like to create a table to display information from a query. The table has 4 columns, so the 5th record should be displayed in the 1st column of the 2nd row, the 9th record in the 1st column of the 3rd row, etc.
This is the code
Code:
//columns in the table
$columns=4;
$column_width=100/$columns;
<table width="100%" border="1" cellpadding="5" cellspacing="5" bordercolor="#FFFFFF">
<tr>
<td height="30" colspan="1" class="newstitle"><div align="left"><?php echo $department_name; ?></div></td>
</tr>
<?php
do {
$cells=1;
?>
<tr>
<?php
while ($cells<=$columns) {
if ($row_retailer_list['retailer']==NULL) {
$border_colour='FFFFFF';
$retailer=' ';
} else {
$border_colour='B2B2B2';
$retailer='<a href="' . $_SERVER['PHP_SELF'] . '?select_retailer=' . $row_retailer_list['retailer_id'] . '"><p class="shoppingname">' . $row_retailer_list['retailer'] . '<br><span class="shoppinggrey">Please click here for shop details</span></p></a>';
}
?>
<td width="<?php echo $column_width; ?>%" height="60" bordercolor="#<?php echo $border_colour; ?>"><?php echo $retailer; ?></td>
<?php
$cells++;
$row_retailer_list = mysql_fetch_assoc($retailer_list);
}
?>
</tr>
<?php
echo $row_retailer_list['retailer'];
} while ($row_retailer_list = mysql_fetch_assoc($retailer_list));
?>
</table>
The problem is that it's not displaying every 5th record as I'm skipping it by using $row_retailer_list = mysql_fetch_assoc($retailer_list) twice when I start a new row. Is there a function that moves the internal recordset pointer backwards? Or can someone suggest a better way of displaying the table?
Any help would be greatly appreciated.