/    Sign up×
Community /Pin to ProfileBookmark

Urgent help… multiple search criteria…

Hi guys

I am out of nay clue or idea plz help me

below is my code for multiple search criteria from sql database. I am not getting any idea how to do it. I would like to have 10 records displayed per page after search, means I need pagination also.. I am able to get all the result in one page but not working with pagination…

any one can guide me ??

search .php

[CODE]<form name=”filterlist” id=”filterlist” method=”POST” action=”filter-list.php”>
<tr>
<td width=”180″ height=”30″><select size=”1″ name=”type”>
<option selected value=”0″>- Select Type -</option>
<option value=”1″>Road</option>
<option value=”2″>Air</option>
<option value=”3″>water</option>
</select></td>
<td width=”122″ height=”30″><select size=”1″ name=”day”>
<option selected value=”0″>- Select Day -</option>
<option value=”1″>1</option>
<option value=”2″>2</option>
<option value=”3″>3</option>
</select></td>
<td width=”172″ height=”30″>
<select size=”1″ name=”month”>
<option selected value=”0″>- Select Month -</option>
<option value=”1″>January</option>
<option value=”2″>February</option>
<option value=”3″>March</option>
</select></td>
<td width=”156″ height=”30″>
<select size=”1″ name=”year”>
<option value=”0″ selected>– Select Year –</option>
<option value=”2009″>2009</option>
<option value=”2010″>2010</option>
<option value=”2011″>2011</option>
</select></td>
<td width=”159″ height=”30″>
<select size=”1″ name=”status”>
<option value=”0″>- Select Status -</option>
<option value=”1″>Online</option>
<option value=”2″>Offline</option>
</select></td>
<td width=”67″ height=”30″>
<input type=”submit” name=”submit” value =”Filter” >
</td>
</tr>
</form>[/CODE]

filter-list.php

[CODE]// get variable values
$filter_type = $_POST[‘type’];
$filter_day = $_POST[‘day’];
$filter_month = $_POST[‘month’];
$filter_year = $_POST[‘year’];
$filter_status = $_POST[‘status’];

// get SQL QUERY
if ($filter_type <>’0′ && $filter_day ==’0′ && $filter_month ==’0′ && $filter_year ==’0′ && $filter_status ==’0′){
$sql = “type = ‘$filter_type'”;

} else if ($filter_type ==’0′ && $filter_day <>’0′ && $filter_month ==’0′ && $filter_year ==’0′ && $filter_status ==’0’){
$sql = “day = ‘$filter_day'”;

} else if ($filter_type ==’0′ && $filter_day ==’0′ && $filter_month <>’0′ && $filter_year ==’0′ && $filter_status ==’0’){
$sql = “month = ‘$filter_month'”;

} else if ($filter_type ==’0′ && $filter_day ==’0′ && $filter_month ==’0′ && $filter_year <>’0′ && $filter_status ==’0’){
$sql = “year = ‘$filter_year'”;

} else if ($filter_type ==’0′ && $filter_day ==’0′ && $filter_month ==’0′ && $filter_year ==’0′ && $filter_status <>’0’){
$sql = “status = ‘$filter_status'”;

} else if ($filter_type <>’0′ && $filter_day <>’0′ && $filter_month <>’0′ && $filter_year <>’0′ && $filter_status <>’0’){
$sql = “type = ‘$filter_type’ AND day = ‘$filter_day’ AND month = ‘$filter_month’ AND year = ‘$filter_year’ AND status = ‘$filter_status'”;
}

$sql = “SELECT * FROM $tbl_name WHERE “. $sql .” ORDER BY id DESC LIMIT $start, $limit”;
$result = mysql_query($sql);

[/CODE]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @jack001 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...