rezajooni
پنج شنبه 25 اردیبهشت 1393, 00:12 صبح
من تو صفحه بندی مطالب از کد زیر استفاده میکنم :
<?php
$p="select * from news order by date desc limit ".$_GET['at'].",2";
$r=mysql_query($p);
while ($rows= mysql_fetch_assoc($r)){
echo '<p><a href="page.php?news_id='.$rows['newsid'].'">'.$rows['title'].'</a></p><br />
<p><img src ="adminpanel/news/pic.php?id='.$rows['newsid'].'" width=50 height=50/></p>
<br />';
}
$p="select * from news";
$r=mysql_query($p);
$n= mysql_num_rows($r);
$k=2;
for ($i = 0; $i < ceil($n / $k); $i++) {
echo '<a href=?at=' . $i * $k . '>' . ($i + 1) . '</a> | ';
}
?>
و صفحات رو به خوبی میاره ولی وقتی به صفحه اصلی بر میگردم ارور میده:
Notice: Undefined index: at in C:\wamp\www\sabalanhospital\index.php on line 98
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\sabalanhospital\index.php on line 100
لطفا راهنمایی کنید
<?php
$p="select * from news order by date desc limit ".$_GET['at'].",2";
$r=mysql_query($p);
while ($rows= mysql_fetch_assoc($r)){
echo '<p><a href="page.php?news_id='.$rows['newsid'].'">'.$rows['title'].'</a></p><br />
<p><img src ="adminpanel/news/pic.php?id='.$rows['newsid'].'" width=50 height=50/></p>
<br />';
}
$p="select * from news";
$r=mysql_query($p);
$n= mysql_num_rows($r);
$k=2;
for ($i = 0; $i < ceil($n / $k); $i++) {
echo '<a href=?at=' . $i * $k . '>' . ($i + 1) . '</a> | ';
}
?>
و صفحات رو به خوبی میاره ولی وقتی به صفحه اصلی بر میگردم ارور میده:
Notice: Undefined index: at in C:\wamp\www\sabalanhospital\index.php on line 98
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\sabalanhospital\index.php on line 100
لطفا راهنمایی کنید