Blätterfunktion geht ned?

vodka

Mitglied
Also ich hab mal versucht eine Blätterfunktion in mein News system einzubauen!
Aber leider geht was ned!
Hier mal der Code:

PHP:
<?php
// Zur config datei Includen //
include "admin/dbnews.php";

// Verbindung mit der Datenbank erstellen //
$db = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");

$offs = $_GET["offs"];
$num = $_GET["num"];



$query = "SELECT *, DATE_FORMAT(datum,'%d.%m.%Y') AS datum_de FROM $tabelle ORDER BY id DESC LIMIT $offs, $num";
$result = mysql_query($query);
while($r=mysql_fetch_array($result))

{
$name=$r["name"];
$titel=$r["titel"];
$news=$r["news"];
$email=$r["email"];
$link=$r["link"];
$datum=$r["datum_de"];
$id=$r["id"];
$bild=$r["bild"];


$s1 = "SELECT  * FROM $tabellec  WHERE newsid = '$id'" ;
$q1 = mysql_query($s1) ;
$c = mysql_num_rows($q1) ;



echo "<table style='BORDER-COLLAPSE: collapse'
table width='424' border='1' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000'>
  <tr bgcolor='#666666'>
    <td width='276'>
      <div align='left'><font color='#FFFFFF'><strong>$titel
        </strong></font></div></td>
    <td width='142'>
      <div align='center'><font color='#FFFFFF'><strong><a href='mailto:$email'>$name</a></strong></font></div></td>
  </tr>
  <tr>
    <td colspan='2'><table width='419' border='0' cellspacing='10'>
        <tr>
          <td width='74'><img src='$bild' width='60' height='58'></td>
          <td width='311'>$news</td>
        </tr>
      </table>
      <table width='419' border='0'>
        <tr>
          <td width='303'><p align='left'><strong><font size='2'>Links: </font></strong><a href='$link'><font size='2'>$link</font></a></p>

</td>
<td width='106'><div align='center'><a href='$comments
comments.php?id=$id'>comments($c)</a></div></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table width='425' border='0' align='center'>
  <tr>
    <td width='302' height='21'>
<div align='right'></div></td>
    <td width='113'><div align='center'><strong><font size='2'>$datum</font></strong></div></td>
  </tr>
</table>
<table width='425' border='0' align='center'>
  <tr>
    <td width='302' height='21'> <div align='right'></div></td>
    <td width='113'><div align='center'><strong></strong></div></td>
  </tr>
</table>";
}

$actual_page = ($offs / $num) + 1;
// Navigationsleiste << 1 2 .... >>
echo "Seite: ";
if ($actual_page != 1)
{
    $foo = $offs - $num;
    echo "<a href='?num=$num&offs=$foo'>&lt;&lt;</a>&nbsp;";
} else {
    echo "&nbsp;&nbsp;&nbsp;&nbsp;";
}

if (ceil ($all / $num) > 10)
{
    $min = $actual_page - 10;
    if ($min <= 0)
    {
        $min = 0;
    } else {
        echo "<a href='?num=$num&offs=0' class='link'>1</a>&nbsp;...";
    }
    $max = $actual_page + 10;
    if ($max > ceil ($all / $num) )
    {
        $max = ceil ($all / $num);
    }
} else {
    $min = 0;
    $max = ceil ($all / $num);
}
for ($i = $min; $i < $max; $i++)
{
    $foo = $i + 1;
    $offsfoo = $i * $num;
    if ($actual_page != $i + 1)
    {
        echo "<a href='?num=$num&offs=$offsfoo'>$foo</a>&nbsp;";
    } else {
        echo "<u>$foo</u>&nbsp;";
    }
}
if (ceil ($all / $num) > 10 && $actual_page + 10 < ceil ($all / $num) )
{
    $offsfoo = (ceil ($all / $num) - 1) * $num;
    $foo = ceil ($all / $num);
    echo "...<a href='?num=$num&offs=$offsfoo'>$foo</a>&nbsp;";
}
if ($actual_page < ceil ($all / $num) )
{
    $foo = $offs + $num;
    echo "<a href='?num=$num&offs=$foo'>&gt;&gt;</a>&nbsp;";
} else {
    echo "&nbsp;&nbsp;&nbsp;&nbsp;";
}
// ENDE der Navigationsleiste

?>
Und folgende Fehlermeldung erscheint:
Fehlermeldung
An was kann das liegen?
 
Den Code von meinem Gästebuch... den kriegt keiner.
Vielleicht schreib ich des mal für GPL :)
Schließlich is des 100% mein Code und NICHT aus Tutorials.

Nein, ich meinte nicht: "Ich habe den Code aus dem Tutorial und der geht",
sondern: "Deine Seite war aufrufbar!" ...

Die Seite wurde aufgerufen, und ich konnte blättern. Seltsam, jetzt erscheint:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/dalton/public_html/php/fertige scripts/news/view.php on line 16
0

Hast Du den Code geändert?

So kann man wohl schlecht helfen ...
 
Zuletzt bearbeitet:
Ja ich hab was geändert neue code:

PHP:
<?php
// Zur config datei Includen //
include "admin/dbnews.php";

// Verbindung mit der Datenbank erstellen //
$db = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");

$proseite = "2";

$start=$page * $proseite;
$sql="SELECT * FROM $tabelle LIMIT $start,$proseite";
$result = mysql_query($sql,$db);


$ende = $start + $proseite;
if ($ende>$number) { $ende = $number;
}
while ($r = mysql_fetch_array($result))
{
$name=$r["name"];
$titel=$r["titel"];
$news=$r["news"];
$email=$r["email"];
$link=$r["link"];
$datum=$r["datum_de"];
$id=$r["id"];
$bild=$r["bild"];


$s1 = "SELECT  * FROM $tabellec  WHERE newsid = '$id'" ;
$q1 = mysql_query($s1) ;
$c = mysql_num_rows($q1) ;



echo "<table style='BORDER-COLLAPSE: collapse'
table width='424' border='1' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000'>
  <tr bgcolor='#666666'>
    <td width='276'>
      <div align='left'><font color='#FFFFFF'><strong>$titel
        </strong></font></div></td>
    <td width='142'>
      <div align='center'><font color='#FFFFFF'><strong><a href='mailto:$email'>$name</a></strong></font></div></td>
  </tr>
  <tr>
    <td colspan='2'><table width='419' border='0' cellspacing='10'>
        <tr>
          <td width='74'><img src='$bild' width='60' height='58'></td>
          <td width='311'>$news</td>
        </tr>
      </table>
      <table width='419' border='0'>
        <tr>
          <td width='303'><p align='left'><strong><font size='2'>Links: </font></strong><a href='$link'><font size='2'>$link</font></a></p>

</td>
<td width='106'><div align='center'><a href='$comments
comments.php?id=$id'>comments($c)</a></div></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table width='425' border='0' align='center'>
  <tr>
    <td width='302' height='21'>
<div align='right'></div></td>
    <td width='113'><div align='center'><strong><font size='2'>$datum</font></strong></div></td>
  </tr>
</table>
<table width='425' border='0' align='center'>
  <tr>
    <td width='302' height='21'> <div align='right'></div></td>
    <td width='113'><div align='center'><strong></strong></div></td>
  </tr>
</table>";
}
if ($page>0) {
    $i=$page-1;
    echo "<A HREF=\"guestbook.php?page=$i\">&lt;previous</A>";
}
for($i=0; $i<=$seiten; $i++) {
    if ($i==$page) {
        echo $i."&nbsp;";
    }
    else {
        echo "<A HREF=\"guestbook.php?page=$i\">$i</A>&nbsp;";
    }
}
if ($page<$seiten) {
    $i=$page+1;
    echo "<A HREF=\"guestbook.php?page=$i\">next&gt;</A>";
}

?>

Aber geht immer noch nicht
 
Zurück