paging

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 







Does anyone have a link to any examples of paging?



I have this example up and running,



http://www.w3schools.com/php/php_ajax_database.asp



I
have paging working as below, my problem is when I add a CSS style
sheet I now have 4 panes.  How can I direct the paging results to the
"content" pane?



<?php

$q=$_GET["q"];

$start=$_GET["start"];



$con = mysql_connect('localhost', 'root', 'mypassword');

if (!$con)

 {die('Could not connect: ' . mysql_error());}



mysql_select_db("bar", $con);

$page_name="getbars.php";



if(!isset($start)) {$start = 0;}



$sql2="select * from bars WHERE geog_id = '".$q."'";

$result2=mysql_query($sql2);

echo mysql_error();

$nume=mysql_num_rows($result2);



$eu = ($start - 0); 

$limit = 10;

$this1 = $eu + $limit; 

$back = $eu - $limit; 

$next = $eu + $limit; 

$sql="select * from bars WHERE geog_id = '".$q."' limit $eu, $limit";



$result = mysql_query($sql);



echo "<table border='0'>";

while($row = mysql_fetch_array($result))

  {

  if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}

  else{$bgcolor='#f1f1f1';}

    echo "<tr >";

   
//echo "<td align=left bgcolor=$bgcolor
id='title'>&nbsp;<font face='Verdana' size='2'><A
HREF=" . $row['bar_website'] . "  >" . $row['bar_name'] .
"</A></div></font></td>";

        echo "<div id='lbBarList'> </div>";  

       
echo "<td align=left bgcolor=$bgcolor
id='title'>&nbsp;<font face='Verdana' size='2'><A
HREF=" . $row['bar_website'] . "  >" . $row['bar_name'] .
"</A></div></font></td></div>";

  echo "</tr>";

}

echo "</table>";





if($nume > $limit ){ // Let us display bottom links if sufficient records are there for paging

  /////////////// Start the bottom links with Prev and next link with page numbers /////////////////

  echo "<table align = 'center' width='50%'><tr><td  align='left' width='30%'>";

  //// if our variable $back is equal to 0 or more then only we will display the link to move back ////////

   if($back >=0) { 

     print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>"; 

   } 

}

echo "</td><td align=center width='30%'>";



$i=0;

$l=1;

for($i=0;$i < $nume;$i=$i+$limit){

    if($i <> $eu){

    //    echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";

        echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";

    }

        else { echo "<font face='Verdana' size='4' color=red>$l</font>";}

        $l=$l+1;

}



mysql_close($con);
_________________________________________________________________
Windows Live™: Keep your life in sync. 
http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t1_allup_howitworks_022009

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux