استعمل مربع البحث في الاسفل لمزيد من المواضيع
سريع للبحث عن مواضيع في المنتدى
-
11-01-2013, بتوقيت غرينيتش 03:25 PM
#1
مشكله معايا فى تعدد الصفحات
ظ…ط´ظƒظ„ظ‡ ظ…ط¹ط§ظٹط§ ظپظ‰ طھط¹ط¯ط¯ ط§ظ„طµظپط*ط§طھ
رمز PHP:
<code style="white-space:nowrap"> <code> <?
session_start();
$u_id = $_GET['id'];
include ('include/config.php');
$n_sql = mysql_query("select * from users where '$u_id'= id ");
$n_user = mysql_num_rows($n_sql) ;
if(isset($u_id) and !empty($u_id) and isset($n_user) and !empty($n_user) )
{
include ('include/function.php');
include ('libs/function.tag_cloud.php');
include ("libs/Smarty.class.php");
$page = new Smarty;
$adjacents = 3;
$query = "SELECT COUNT(*) as num FROM topic where '$u_id'= user_id order by id DESC";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
/* Setup vars for query. */
$limit = 3; //how many items to show per page
if($page1)
$start = ($page1 - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Get data. */
$query = "SELECT * FROM topic where '$u_id'= user_id order by id DESC LIMIT $start, $limit";
$portfolio = mysql_query($query);
/* Setup page vars for display. */
if ($page1 == 0) $page1 = 1; //if no page var is given, default to 1.
$prev = $page1 - 1; //previous page is page - 1
$next = $page1 + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\">";
//previous button
if ($page1 > 1)
$pagination.= "<a href=\"page.php?page1=$prev&id=$u_id\"> السابق</a>";
else
$pagination.= "<span class=\"disabled\"> السابق</span>";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
}
}
elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if($page1 < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page1)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"page.php?page1=$counter&id=$u_id\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"pages.php?page1=$lpm1&id=$u_id\">$lpm1</a>";
$pagination.= "<a href=\"pages.php?page1=$lastpage&id=$u_id\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page1 && $page1 > ($adjacents * 2))
{
$pagination.= "<a href=\"page.php?page1=1&id=$id\">1</a>";
$pagination.= "<a href=\"page.php?page1=2&id=$id\">2</a>";
$pagination.= "...";
for ($counter = $page1 - $adjacents; $counter <= $page1 + $adjacents; $counter++)
{
if ($counter == $page1)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"page.php?page1=$counter&id=$u_id\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"page.php?page1=$lpm1&id=$u_id\">$lpm1</a>";
$pagination.= "<a href=\"page.php?page1=$lastpage&id=$u_id\">$lastpage</a>";
}
//close to end; only hide early pages
else
{
$pagination.= "<a href=\"page.php?page1=1&id=$u_id\">1</a>";
$pagination.= "<a href=\"page.php?page1=2&id=$u_id\">2</a>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page1)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"page.php?page1=$counter&id=$u_id\">$counter</a>";
}
}
}
//next button
if ($page1 < $counter - 1)
$pagination.= "<a href=\"page.php?page1=$next&id=$u_id\"> التالى</a>";
else
$pagination.= "<span class=\"disabled\"> التالى</span>";
$pagination.= "</div>\n";
}
if(($all = mysql_num_rows($portfolio)) != 0)
{
while($item = mysql_fetch_assoc($portfolio))
{
$data[]= $item;
}
$page->assign('topic',$data);
}
else
{
$page->assign("all",0);
}
$pagination;
$page->assign('pagination',$pagination); </code> </code>
المواضيع المتشابهه
-
بواسطة romaissa في المنتدى لغات البرمجه للويب
مشاركات: 0
آخر مشاركة: 11-01-2013, بتوقيت غرينيتش 03:01 PM
-
بواسطة linnou في المنتدى لغات البرمجه للويب
مشاركات: 0
آخر مشاركة: 11-01-2013, بتوقيت غرينيتش 02:51 PM
-
بواسطة loulou ange في المنتدى لغات البرمجه للويب
مشاركات: 0
آخر مشاركة: 11-01-2013, بتوقيت غرينيتش 02:38 PM
-
بواسطة linnou في المنتدى لغات البرمجه للويب
مشاركات: 0
آخر مشاركة: 11-01-2013, بتوقيت غرينيتش 02:26 PM
-
بواسطة salima في المنتدى لغات البرمجه للويب
مشاركات: 0
آخر مشاركة: 11-01-2013, بتوقيت غرينيتش 09:56 AM
ضوابط المشاركة
- لا تستطيع إضافة مواضيع جديدة
- لا تستطيع الرد على المواضيع
- لا تستطيع إرفاق ملفات
- لا تستطيع تعديل مشاركاتك
-
قوانين المنتدى