Jump to content
php.lv forumi

paskaidrojiet ka so kodu dabut lai strada split pages.


millers
 Share

Recommended Posts

Ja pareizu sapratu, tad viņam nesadalās vairākās lapās.

 

 

 

if(!isset($_GET['lapa'])){
  $lapa = 1;
} else {
  $lapa = $_GET['lapa'];
}
$max_results = 30;
$from = (($lapa * $max_results) - $max_results);
$sql = mysql_query("SELECT * FROM cw_rezultati ORDER BY id DESC LIMIT $from, $max_results");



$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM cw_rezultati"),0);
$total_pages = ceil($total_results / $max_results);

echo "".$lang['lapa'].": ";

if($lapa > 1){
  $prev = ($lapa - 1);
  echo "<a href=\"".$_SERVER['PHP_SELF']."?lapa=$prev\"></a> ";
}
for($i = 1; $i <= $total_pages; $i++){
  if(($lapa) == $i){
   echo "$i ";
   } else {
	   echo "<a href=\"".$_SERVER['PHP_SELF']."?lapa=$i\"><b>$i</b></a> ";
  }
}

if($lapa < $total_pages){
  $next = ($lapa + 1);
  echo "<a href=\"".$_SERVER['PHP_SELF']."?lapa=$next\"></a>";
}

Link to comment
Share on other sites

a kada man datubaze ieksa mysql jauztaisa ? un ieksa datubazes kadas tabulas?

A kam par godu ieliki šo linku ja pats rakstīji kodu, tad tākā jāzin ko raksti

Tur tev pašam norādīts

SELECT id FROM tbl_name

tbl_name ir tās tabulas nosaukums

Edited by phpjanis
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...