Jump to content
php.lv forumi

Palīdziet sadalit pa lapam


sickman

Recommended Posts

man vajag lai šo scriptu piem varētu sadalīt pa lapām vienas ziņas tabuliņa vienā lapā! esmu nočakarējies līddz bezsamaņai nekas neiznāāk :(

<table cellspacing="0px" width="100%">
<tr>
<td valign="top">
<h3>Jaunumi</h3>
<?php
$db = mysql_connect("localhost","jaaajaaa","startstart") or die(mysql_error());
mysql_select_db("php_lapa",$db );
$result = mysql_query("SELECT ID, title, date, description, author  FROM jaunumi",$db);
$myrow = mysql_fetch_array($result);
do {
printf(" <table class='lessons' align='center'>
<tr>
<td class='lessons_title'><p class='lesson_name'><a href='view_news.php?ID=%s'> %s</a></p>
<p class='lesson_adds'>Pievienoрanas datums: %s</p>
<p class='lesson_adds'>Autors: %s</p></td>
</tr>
<tr>
<td>%s<td>
</tr>
</table><br> <br>",$myrow["ID"], $myrow["title"],$myrow["date"],$myrow["author"], $myrow["description"]);
}
While ($myrow =mysql_fetch_array($result));
?>
</td>
</tr>
</table>

Link to comment
Share on other sites

Nu, ja esi izgājis visādus veidus, tad vajadzētu beidzot pamēģināt no foruma satura paņemt ;)

neesu jau naglijs bet kaads nevar paliidzeet uzreiz sadaliit es no kodeeshanas veel iisti neko nerubiiju daudz taakaa paliidziiba man nodereetu!

Link to comment
Share on other sites

Link to comment
Share on other sites

ahh.. chizijs, ka vienmēr palīdzēs nabadziņiem ^^

<?php
if(!isset($_GET['page'])){
  $lapa = 1;
}else{
  $lapa = $_GET['page'];
}
$max = 10;
$no = (($lapa * $max) - $max);
$tabula = "Mana tabula";
$sql = mysql_query("SELECT * FROM `'".$tabula."'` ORDER BY id DESC LIMIT $no, $maxs");
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM `'".$tabula."'`"),0);
$total_pages = ceil($total_results / $max_results);
?>
<?php
if(mysql_num_rows($sql) > 0){
while($t = mysql_fetch_array($sql)){
?>
<?php echo $t['kolona']; ?>
<?php } ?>
<?php
if($lapa > 1){
  $prev = ($lapa - 1);
  echo "<span class=\"pagecurrent\"><a href=\"?p=page=$prev\">«</a></span>";
}
for($i = 1; $i <= $total_pages; $i++){
  if(($lapa) == $i){
      echo "<span class=\"pagecurrent2\">$i</span>";
      } else {
          echo "<span class=\"pagecurrent\"><a href=\"?p=page=$i\"><b>$i</b></a></span>";
  }
}
if($lapa < $total_pages){
  $next = ($lapa + 1);
  echo "<span class=\"pagecurrent\"><a href=\"?p=page=$next\">»</a></span>";
}
?>

Tikai labo pats..

Edited by chizijs
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...