Sephy Posted August 7, 2011 Report Share Posted August 7, 2011 (edited) Vajadzīgs pamainīt mainīga $rakstanr vērtību uz linka "nākamais" vai "iepriekšējais" uzspiešanas un palaist automātiski skriptu vēlreiz! Kā lai to izdara vai vismaz iedodiet labus key wordus priekš google lūdzu Te ir kods. <?php $dbhost = 'localhost'; $dbuser = 'aaaa'; $dbpass = 'wtf'; $dbname = 'nono'; $rakstanr = '1'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname) or die ('Cannot select database'); $check = mysql_query("SELECT * FROM news ORDER by newid ASC LIMIT ".$rakstanr."") or die(mysql_error()); $zinas = mysql_num_rows($check); while($info = mysql_fetch_array( $check )) { ?> <div class="raksts" style="padding-top:15px;"> <table style="width:415px;color: #90003a;text-align:center;font: 14px verdana, sans-serif;margin: 0 auto;"> <tr id="rakstaaugsha" style=""> <td><?php echo($check[0 - $zinas] . ' ' . $info['newsname'] . '<br />');?></td> <td style="width:40px;"><?php echo($check[0 - $zinas] . ' ' . $info['createnews'] . '<br />');?></td> </tr> </table><br> <table style="width:415px;margin-left:-5px;"> <tr id="rakstaaugsha"> <td id="patsraksts" style="border-left:1px solid white;color: #1f5400;text-align:left;padding-left:10px;"><?php echo($check[0 - $zinas] . ' ' . $info['newstext'] . '<br />');?></td> </tr> </table> </div><br> <div id="skruller"><a class="next" href="#">Iepriekšējais</a><a class="prev" href="#" style="padding-left:20px;">Nākamais</a></div> <?php } ?> Edited August 7, 2011 by Sephy Quote Link to comment Share on other sites More sharing options...
Code Posted August 7, 2011 Report Share Posted August 7, 2011 Tepat forumā - tēmu apkopojumā. Pašķir zemāk līdz datu bāzu sadaļai (ierakstu dalīšana pa lappusēm). Quote Link to comment Share on other sites More sharing options...
Sephy Posted August 7, 2011 Author Report Share Posted August 7, 2011 Oki paldies, apskatīšos, es skatījos pie php un tālāk nepaskatījos xD Quote Link to comment Share on other sites More sharing options...
Sephy Posted August 8, 2011 Author Report Share Posted August 8, 2011 (edited) Viss strada, paldies forumam ;) Te ir kods ja nu vel kadam biedram vajag! <?php $dbhost = 'localhost'; $dbuser = 'dadsadsadasds'; $dbpass = 'dsadsadsa'; $dbname = 'sssaasa'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname) or die ('Cannot select database'); if(!isset($_GET['news'])){//Parbauda paslaikejo lapu, $news = 1; } else { $news = $_GET['news']; } $max_results = 1;//Cik daudz rakstus reize radit $from = (($news * $max_results) - $max_results);//No kura raksta sakt radit $check = mysql_query("SELECT * FROM news ORDER by newid ASC LIMIT $from,$max_results") or die(mysql_error()); $zinas = mysql_num_rows($check); while($info = mysql_fetch_array( $check )) { $filename=$info['address'];//apstradajam bildi lai ietilpu vajadziga izmera include('jaunsizmers.php'); $image = new SimpleImage(); $image->load($filename); $image->resizeToWidth(250); $image->save('sgbildes/hurrdurr.jpg'); ?> <div id="tekstsgohere"> <div id="bildesvieta"><div id="bildite" style="background: url('sgbildes/hurrdurr.jpg') no-repeat;"></div></div> <div id="tekstaizvade"> <div class="raksts" style="padding-top:15px;"> <table style="width:415px;color:#90003a;text-align:center;font: 14px verdana, sans-serif;margin: 0 auto;"> <tr id="rakstaaugsha"> <td><?php echo($check[0 - $zinas] . ' ' . $info['newsname'] . '<br />');?></td><!--Izvadam zinas un apaksa datumu--> <td style="width:40px;"><?php echo($check[0 - $zinas] . ' ' . $info['createnews'] . '<br />');?></td> </tr> </table><br> <table style="width:415px;margin-left:-5px;"> <tr id="rakstaaugsha"> <td id="patsraksts" style="border-left:1px solid white;color: #1f5400;text-align:left;padding-left:20px;"><?php echo(nl2br($check[0 - $zinas] . ' ' .$info['newstext']. '<br />'));?></td> </tr> </table> </div><br> <div id="skruller"> <?php $com_query = mysql_query("select count(*) from news"); $com_row = mysql_fetch_row($com_query); $total_results = "".$com_row[0]."";// kopejais ierakstu skaits $total_pages = ceil($total_results / $max_results); // "Previous" saite if($news > 1){ $prev = ($news - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?news=$prev\">Iepriekšējais</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($news) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?news=$i\">$i</a> "; } } // "Next" saite if($news < $total_pages){ $next = ($news + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?news=$next\">Nākamais</a>"; } echo "</center>"; ?> </div></div> </div> <?php } ?> Edited August 8, 2011 by Sephy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.