0
我正在使用這個pagination class,並正在尋找一種方法使sql查詢更具動態性,而不是硬編碼。如何使sql查詢動態?
我有一個3 <li>
元素,我想要過濾按鈕,這意味着當用戶點擊這些元素之一,我想它發送的ID,所以我可以在SQL查詢中使用它。
因此對於$sql = "select * from explore where category='marketing'";
(如下所示)。當用戶點擊「汽車」按鈕時,它會將上述類別更改爲汽車。
對此的任何幫助將不勝感激,謝謝。
這是我的主要頁面的樣子:
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery_page.js"></script>
<?php
//Include the PS_Pagination class
include('ps_pagination.php');
//Connect to mysql db
$conn = mysql_connect('localhost', 'root', 'root');
mysql_select_db('ajax_demo',$conn);
$sql = "select * from explore where category='marketing'";
//Create a PS_Pagination object
$pager = new PS_Pagination($conn, $sql, 3, 11, 'param1=valu1¶m2=value2');
//The paginate() function returns a mysql
//result set for the current page
$rs = $pager->paginate();
//Loop through the result set
while($row = mysql_fetch_assoc($rs)) {
echo "<table width='800px'>";
echo "<tr>";
echo"<td>";
echo $row['id'];
echo"</td>";
echo"<td>";
echo $row['site_description'];
echo"</td>";
echo"<td>";
echo $row['site_price'];
echo"</td>";
echo "</tr>";
echo "</table>";
}
echo "<ul id='pagination'>";
echo "<li>";
//Display the navigation
echo $pager->renderFullNav();
echo "</li>";
echo "</ul>";
echo "<ul id='filter'>";
echo "<li id='marketing'>";
echo "Marketing";
echo "</li>";
echo "<li id='automotive'>";
echo "Automotive";
echo "</li>";
echo "<li id='sports'>";
echo "Sports";
echo "</li>";
echo "</ul>";
?>
http://stackoverflow.com/questions/2231538/pagination-problem-needing-assistance – CheeseConQueso 2010-03-23 19:42:20
http://stackoverflow.com/questions/1064167/php-pagination-problem-displaying-correct-content-on-additional-pages – CheeseConQueso 2010-03-23 19:42:45
http://stackoverflow.com/questions/2308169/change-queries-dynamically-php- jQuery的 – CheeseConQueso 2010-03-23 19:45:01