puck Posted March 16, 2010 Report Share Posted March 16, 2010 Kā iedalīt cutenews UTF-8 pa lappusēm? Piem. 5 raksti jauna lapa u.t.t Link to comment Share on other sites More sharing options...
baBykoRn* Posted March 17, 2010 Report Share Posted March 17, 2010 jā, es to pašu vēlos uzzināt.. Link to comment Share on other sites More sharing options...
DoubleT Posted March 17, 2010 Report Share Posted March 17, 2010 (edited) šito ieliec, kur gribi attēlot pagination sistēmu. PHP <? $perpage =15; $_LIMIT=(!empty($_GET['p']) && $_GET['p']>1)?($_GET['p']*$perpage)-$perpage:0; $_LIMIT.=", ".$perpage $kopa = mysql_result(mysql_query("SELECT * FROM tabula"),0); dalit($kopa,$perpage,"http://links_uz_lapu_kur_tiek_attēlots"); ?> šite ir dalit f-ja PHP <? function dalit($kopa,$vienalapa,$links) { echo "<table align=center><tr>"; $starpa = 4; $lapas = ceil($kopa/$vienalapa); if( $lapas<2) { echo ""; } else { $lapa = (empty($_GET['p']) || $_GET['p']<2) ? 1 : $_GET['p']; $pirma = $lapa >= $starpa+1 ? $lapa-$starpa : 1; $pedeja = $lapa <= $lapas-$starpa ? $lapa+$starpa : $lapas; if( $lapa>1){ $viss.= sprintf('<td id=first><a class=menu href="'.$links.'?p=1"> </a></td><td id=prev><a href="'.$links.'?p=%d"> </a></td>', $lapa-1); } for( $i=$pirma;$i<=$pedeja;$i++){ $viss.= sprintf('<td class=square><a%s href="'.$links.'?p=%d">%d</a></td>', $lapa==$i ? ' class="active"' : '', $i, $i); } if( $lapa<$lapas){ $viss.= sprintf('<td id=next><a href="'.$links.'?p=%d"> </a></td><td id=last><a href="'.$links.'?p=%d"> </a></td>', $lapa+1, $lapas); } echo $viss; } echo "</tr></table>"; } ?> šī skripta priekšrocība ir tā, ka vari izmantot vairākās vietās tikai iekopējot tajā lapā kodu, ko liec jaunumu lapā ( gadījumā ja f-ja stāv citā failā ). ja f-ju liec atsevišķā failā ( piem. funkcijas.php ) tad neaimirsti to failu inklūdot. NB! vietā kur izsauc tos rakstus ( ciklā ) pirms while cikla kvērijā neaizmirsti beigās pielikt LIMIT ".$_LIMIT Edited March 17, 2010 by DoubleT Link to comment Share on other sites More sharing options...
X ID Posted March 17, 2010 Report Share Posted March 17, 2010 Man tas tavs kods līks izskatās.. Precīzāk pirmā daļa un mainīgais $kopa Link to comment Share on other sites More sharing options...
DoubleT Posted March 17, 2010 Report Share Posted March 17, 2010 kas tieši tev tur nepatīk? Link to comment Share on other sites More sharing options...
w4p1337 Posted March 17, 2010 Report Share Posted March 17, 2010 (edited) $kopa = mysql_result(mysql_query("SELECT * FROM tabula"),0); tas vai tad būs daudzums? nevajadzētu COUNT(*)? Edited March 17, 2010 by w4p1337 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now