السلام عليكم
كيفكم شباب إن شاء الله بخير
عندي سؤال عن كود تقسيم النتائج
انا عندي كود بيطالع من قاعدة البيانات صفحات مقسمة كل وحدة فيها 5
لكن بهل كود ما بياخد عدد أسطر البيانات وبيقسمهم إلى صفحات بيدون ما يأظهرهم
بيطلع بس هيك
السابق 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 التالي
Include 'conn.php';
$conn = mysql_select_db('database',$con);
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
// === عدد المواضيع اللتي تظهر في الصفحة الثانية === //
$limit = "5";
$next = "page";
// التأكد من وجود عدد لتلافي الأخطأ //
empty($GLOBALS[$next]);
if(!ereg("[0-9]", $GLOBALS[$next]))
{$GLOBALS[$next] = '0';}
$select = "select * from sale";
$total_result = mysql_num_rows(mysql_query($select));
$result=mysql_query("SELECT * FROM sale");
while ($row=mysql_fetch_array($result)) {
$text=$row[comment];
$text=str_replace(":)","<img src='images/laugh.gif'>",$text);}
$select .= " LIMIT ".$GLOBALS[$next].", ".$limit;
$sql_result = mysql_query($select);
// كتابة التالي والسابق //
$bk = "<font face='Wingdings 3' size='1'>}</font> السابق";
$nx = "التالي <font face='Wingdings 3' size='1'>|</font>";
// عملية إخراج ناتج التالي وناتج السابق //
$A = $limit + $GLOBALS[$next];
$B = $GLOBALS[$next] - $limit;
print '<center><table dir="rtl" width="100%" ><tr>
<td align="center">';
// أداة شرطية لتأكد من أن عدد المواضيع أكثر من العدد المحدد لصفحة الواحدة //
if($total_result > $limit) {
// === الحالة الأولى تشغيل السابق بصفر والتالي === //
if($A < $total_result && $GLOBALS[$next] <> 0 && !($B >= 0))
{print "<a href='$GLOBALS[PHP_SELF]?$next=0'>$bk</a> ";
$a3dd = ceil($total_result / $limit);
for ($i = 0; $i < $a3dd; $i++)
{$ii = $i + 1;
$url = $ii * $limit - $limit;
if ($ii >= $a3dd) {$kat = "";}
else {$kat = " | ";}
if($GLOBALS[$next] <> $url)
{print("<a href='$GLOBALS[PHP_SELF]?$next=$url' Title='الصفحة رقم $ii'>$ii</a>$kat");}
else {print ("$ii$kat");}}
print " <a href='$GLOBALS[PHP_SELF]?$next=$A'>$nx</a>";}
// === الحالة الثانية تشغيل التالي فقط === //
elseif($A < $total_result && $B < 0 )
{print "$bk ";
$a3dd = ceil($total_result / $limit);
for ($i = 0; $i < $a3dd; $i++)
{$ii = $i + 1;
$url = $ii * $limit - $limit;
if ($ii >= $a3dd) {$kat = "";}
else {$kat = " | ";}
if($GLOBALS[$next] <> $url)
{print("<a href='$GLOBALS[PHP_SELF]?$next=$url' Title='الصفحة رقم $ii'>$ii</a>$kat");}
else {print ("$ii$kat");}}
print " <a href='$GLOBALS[PHP_SELF]?$next=$A'>$nx</a>";}
// === الحالة الثالثة تشغيل السابق والتالي === //
elseif($A < $total_result && $B >= 0 )
{print "<a href='$GLOBALS[PHP_SELF]?$next=$B'>$bk</a> ";
$a3dd = ceil($total_result / $limit);
for ($i = 0; $i < $a3dd; $i++)
{$ii = $i + 1;
$url = $ii * $limit - $limit;
if ($ii >= $a3dd) {$kat = "";}
else {$kat = " | ";}
if($GLOBALS[$next] <> $url)
{print("<a href='$GLOBALS[PHP_SELF]?$next=$url' Title='الصفحة رقم $ii'>$ii</a>$kat");}
else {print ("$ii$kat");}}
print " <a href='$GLOBALS[PHP_SELF]?$next=$A'>$nx</a>";}
// === الحالة الرابعة تشغيل السابق === //
elseif($A >= $total_result && $B >= 0 )
{print "<a href='$GLOBALS[PHP_SELF]?$next=$B'>$bk</a> ";
$a3dd = ceil($total_result / $limit);
for ($i = 0; $i < $a3dd; $i++)
{$ii = $i + 1;
$url = $ii * $limit - $limit;
if ($ii >= $a3dd) {$kat = "";}
else {$kat = " | ";}
if($GLOBALS[$next] <> $url)
{print("<a href='$GLOBALS[PHP_SELF]?$next=$url' Title='الصفحة رقم $ii'>$ii</a>$kat");}
else {print ("$ii$kat");}}
print " $nx";}}
mysql_close($con);كيف بدي أربط بين الكود السابق وهل كود
$result = mysql_query("SELECT * FROM sale");
while($row = mysql_fetch_array($result))
{
echo $row['city'] . " " . $row['area']. " " . $row['buildingnumber']. " " . $row['anyfloor']. " " . $row['roomsnumber']. " " . $row['housesurveyor']. " " . $row['price']. " " . $row['name']. " " . $row['email'];
echo "<br />";
}يعني يصير بكل صفحة من الصفحات يطلع معي 5 أسطر
والسلام ختااام