Jump to content
php.lv forumi

postu dalīšana pa lapām


djmartins

Recommended Posts

Lieta taada ka man tie posti vienaa lapaa radas kaut kur jau pie 100 un tas palelina lapas ieladesanos un nav eerti lietotajiem!Kaa lai uztaisa lai vienaa lapaa butu redzami tikai 10 posti un paarejie nakamajas lapas pec principa 1 2 3

<?

$host == "localhost";

$port == "3306";

$user == "klauns";

$pass == "subaru";

$database == "news";

$db = mysql_connect("$host:$port", "$user", "$pass");

$result = mysql_query("SELECT * FROM news WHERE cat='$cat' ",$db);

while ($res = mysql_fetch_array($result)) }

echo("<table width=609 valign=top align=center>");

echo("<td colspan=3 align=center><a href=\"arhive.php?newsid=$res[newsid]\">$res[2]</a></td>");

echo("</table>");

}

?>

Link to comment
Share on other sites

$cik = 15 // ievadi cik ierakstus veelies redzeet lapaa
if(empty($_GET['lpp'])){ $lpp = 0; }
$start = $_GET['lpp'] * $cik;
$result = mysql_query("SELECT * FROM news WHERE cat='$cat' LIMIT $start, $cik ",$db);

Edited by MakaTaNaw
Link to comment
Share on other sites

tad uztaisi lai dala pa lapaam!

$kopa_raksti = mysql_query("SELECT COUNT(*) FROM tabula");
$kopa_raksti = mysql_fetch_row($kopa_raksti);
$kopa_raksti = $kopa_raksti[0];

$cik_lapas = ceil($kopa_raksti / $cik) /* izskaitljo cik lapas buus, jo dala visus ierakstus ar tik cik paradas lapaa */

if($cik_lapas > 0 AND ($lpp + 1) < $cik_lapas){ echo 'Taalaak'; } 

if($lpp > 0) { echo 'atpakalj'; }

 

apmeeram taa

Link to comment
Share on other sites

×
×
  • Create New...