Hi i have a results page which iam trying to add alternating colours. Ive managed that part but part of the code is causeing the next page to displaying more and more results each time its used due to part of the alternating colour script.
heres the code for the alternating bit
PHP Code:
<?
// Define the colours for the alternating rows
$colour_odd = "#FFE680";
$colour_even = "#FFF2BF";
$row_count = 0; //To keep track of row number
//select and diplay one beach and loop
while($row_test=mysql_fetch_array($query)){
//$beach1 = addslashes($row_test['beaches']);
$beach1 = str_replace("'", "’", $row_gbg['beaches']);
$region1 = $row_test['region'];
$country1 = $row_test['county'];
$Ntown1 = $row_test['Ntown'];
$grade051 = $row_test['grade05'];
$life_cover1 = $row_test['life_cover'];
$beach_award1 = $row_test['beach_award'];
$row_color = (($row_count % 2) == 0) ? $colour_even : $colour_odd;
/* Echo the table row and table data that needs to be looped
over until the end of the recordset*/
echo '
<tr bgcolor="' . $row_color . '">
<td width="240"><a href="details.php?BeachName='.$beach1.'" onclick="MM_openBrWindow(\'../details.php?beach='.$beach1.'\',\'\',\'scrollbars=yes,status=no,resizable=1,width=620,height=560,left=202,top=84\');return false">'.$beach1.'</a></td>
<td>' .$region1 .'</td>
<td>' .$country1 .'</td>
<td>' .$Ntown1 .'</td>
<td>' .$grade051 .'</td>
<td>' .$life_cover1 .'</td>
<td><a href="../awards_popup.htm" onclick="MM_openBrWindow(\'../awards_popup.htm\',\'\',\'resizable=yes,width=300,height=260\');return false"> ';
//echo "$beach_award1 <br>";
$bluepic ="<img src='../images/BeachAward_logos/BlueFlag.gif' border='0' /><img src='images/pixel.gif' width='5' border='0' />";
if (substr_count($beach_award1, "BlueFlag") == '1'){echo $bluepic;}
$mcspic ="<img src='../images/BeachAward_logos/MCS_Rec.png' border='0' /><img src='images/pixel.gif' width='5' border='0' />";
if (substr_count($beach_award1, "MCS") == '1'){echo $mcspic;}
$encamspic ="<img src='../images/BeachAward_logos/EncamsSeaside.gif' border='0' /><img src='images/pixel.gif' width='5' border='0' />";
if (substr_count($beach_award1, "Encams") == '1'){echo $encamspic;}
$greenpic ="<img src='../images/BeachAward_logos/GreenCoast.gif' border='0' />";
if (substr_count($beach_award1, "GreenCoast") == '1'){echo $greenpic;}
$rnlipic ="<img src='../images/BeachAward_logos/RNLI.gif' border='0' />";
if (substr_count($beach_award1, "RNLI") == '1'){echo $rnlipic;}
echo "</A></td>
</tr>";
// Increment the row count
$row_count++;
?>
i think its the increment row count part at the bottom.
this is the code that says how many records to show.
PHP Code:
//total number of results
$num_results=mysql_num_rows($query);
echo "$num_results results<BR>";
//number of results to display
$show=10;
if ($start==""){$start=0;}
$end=$start+$show;
//number of current page
$page = ($start/$show)+1;
//how many pages to display
$num_pages = ceil($num_results / $show);
//just for tests
//echo " $page / $num_pages - $num_results results<BR>";
//limit diplay to $show results per page
$limit="LIMIT $start , $end";
$sql2 = $sql . $limit;
$query= mysql_query("$sql2");
//echo $sql2;
?>
Any suggestions on what i can do to stop it affecting this part of the code. Is there a way of cancelling it after its done its job. Your help will be most apreciated as iam so close to what i want.