0
안녕하세요, 페이지 매김 스크립트에 여러 필터를 선택하려고합니다.페이지 매김에 여러 개의 필터를 추가하는 방법은 무엇입니까?
내 페이지 매김에서 사용자가 '마케팅'버튼 (링크)을 클릭하면 마케팅은 해당 카테고리의 데이터베이스 만 쿼리합니다. 아래의 스크립트에서 볼 수있는 다른 2 개의 필터 버튼에 대해서도 마찬가지입니다. (자동차, 스포츠).
문제는 마케팅 및 auomotive 또는 자동차 및 스포츠와 같은 여러 필터를 선택할 수 있기를 원합니다. 예를 들어 마케팅 필터를 클릭 한 다음 자동차를 클릭하면 평등 마케팅 카테고리가 표시됩니다. 자동차.
나는 이것을 수행하는 방법을 모르기 때문에 전문가들을 도와 주었다.
이
내가 작업하고있는 스크립트 (I는 일반적으로 매우 PHP에 새로운 프로그램입니다) :<h3>Filter results by:</h3>
<a href='pagi_test.php?category=marketing'>marketing</a>
<a href='pagi_test.php?category=automotive'>automotive</a>
<a href='pagi_test.php?category=sports'>sports</a>
<br />
<h3>Results:</h3>
<?php
//connecting to the database
$error = "Could not connect to the database";
mysql_connect('localhost','root','root') or die($error);
mysql_select_db('ajax_demo') or die($error);
//max displayed per page
$per_page = 3;
//get start variable
$start = $_GET['start'];
$category = mysql_real_escape_string($_GET['category']);
//count records
$record_count = mysql_num_rows(mysql_query("SELECT * FROM explore WHERE category='$category'"));
//count max pages
$max_pages = $record_count/$per_page; //may come out as decimal
if (!$start)
$start = 0;
//display data
$get = mysql_query("SELECT * FROM explore WHERE category='$category' LIMIT $start, $per_page");
?>
<table width="800px">
<?php
while ($row = mysql_fetch_assoc($get))
{
// get data
$id = $row['id'];
$site_name = $row['site_name'];
$site_description = $row['site_description'];
?>
<tr>
<td><?php echo $id; ?></td>
<td><?php echo $site_name; ?></td>
<td><?php echo $site_description; ?></td>
</tr>
<?php
}
//setup prev and next variables
$prev = $start - $per_page;
$next = $start + $per_page;
//show prev button
if (!($start<=0))
echo "<a href='pagi_test.php?category=$category&start=$prev'>Prev</a> ";
//show page numbers
//set variable for first page
$i=1;
for ($x=0;$x<$record_count;$x=$x+$per_page)
{
if ($start!=$x)
echo " <a href='pagi_test.php?category=$category&start=$x'>$i</a> ";
else
echo " <a href='pagi_test.php?category=$category&start=$x'><b>$i</b></a> ";
$i++;
}
//show next button
if (!($start>=$record_count-$per_page))
echo " <a href='pagi_test.php?category=$category&start=$next'>Next</a>";
?>
답변을 수락하지 않으시겠습니까? – Ben