Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Feb 27, 2006, 04:32   #1
Noppy
SitePoint Addict
 
Join Date: Jan 2005
Location: Hiding from the world
Posts: 225
how do i stop an increment row count

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.
Noppy is offline   Reply With Quote
 

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 02:49.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved