Jump to content

I want to make a filter


Blame

Recommended Posts

I have a MySql table full of records.

 

id

owner

car

location

 

on my page i have these results in a table i want to set a filter up so the table will only show cars from eg location England.

at the minute its just set to show cars that owner has but i want a location filter any help

Link to comment
Share on other sites

<?php
require("connections/db.php");
require("connections/require.php");
require("connections/jailed.php");

$submit = strip_tags($_POST['submit']);
$ros = strip_tags($_POST['ros']);

$play = mysql_query("SELECT * FROM `players` WHERE `playername` = '$player' LIMIT 1")or die(mysql_error());
$arry = mysql_fetch_array($play);

$cash = $arry['money'];

$qry = mysql_query("SELECT * FROM `garage` WHERE `owner` = '$player' ORDER BY `id` DESC")or die(mysql_error());

$num = mysql_numrows($qry);




?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="connections/style.css" />
<script type="text/javascript" src="selectall.js"></script>
</head>
<body>
<form action="" method="post">
<table class="thinline" width="175">
<tr><td class="topic">Show All Cars From:</td>
</tr><tr>
<td>
<select name="lim" class="text">
<option value="X">Everywhere</option>
<option value="England">England</option>
<option value="China">China</option>
<option value="Japan">Japan</option>
<option value="Brazil">Brazil</option>
<option value="South-Africa">South-Africa</option>
<option value="America">America</option><br><input type="submit" value="Show!" class="button" style="margin-top: 4px;">
</td></tr></table>
<br>
<table width="95%" align="center" class="tbl">
<tr><td align="center" class="hdr" colspan="8">.::Garage::.</td></tr>
<tr>
<td align="center" class="sub" width="5%">
<input type="checkbox" name="checkall" onClick="checkUncheckAll(this);">
</td>
<td align="center" class="sub">Type</td>
<td align="center" class="sub">Damage</td>
<td align="center" class="sub">Value</td>
<td align="center" class="sub">Origin</td>
<td align="center" class="sub">Location</td>
<td align="center" class="sub">Repair</td>
<td align="center" class="sub">Sell</td>
</tr>
<? if ($num == 0){ ?>
<tr><td align="center" class="tbl" colspan="8">You don't have any cars.</td></tr>
<? }elseif ($num > 0){
while ($arr = mysql_fetch_array($qry)){
$id = $arr['id'];
$car = $arr['car'];
$dam = $arr['damage'];
$origin = $arr['origin'];
$location = $arr['location'];
$status = $arr['status'];
$value = $arr['value'];

if ($status == 0){
$rep = "<a href=\"?rep=".$id."\">Repair</a>";
}else{
$rep = "Unavailable";
}

if ($status == 0){
$sell = "<a href=\"?sell=".$id."\">Sell</a>";
}else{
$sell = "Unavailable";
}

$car = "<a href=\"".$img."\" target=\"main\">".$car."</a>";
?>
<tr>
<td align="center" class="tbl">
<input type="checkbox" name="radio[]" value="<? print $id; ?>">
</td>
<td align="center" class="tbl"><? print $car; ?></td>
<td align="center" class="tbl"><? print $dam; ?>%</td>
<td align="center" class="tbl"><? print ("$".number_format($value).""); ?></td>
<td align="center" class="tbl"><? print $origin; ?></td>
<td align="center" class="tbl"><? print $location; ?></td>
<td align="center" class="tbl"><? print $rep; ?></td>
<td align="center" class="tbl"><? print $sell; ?></td>
</tr>
<? }} ?>
<tr><td align="center" class="tbl" colspan="8">
<select name="ros">
<option value="sell" Selected>Sell</option>
<option value="rep">Repair</option>
</select>
   
<? sub(submit,Submit); ?>
</td></tr>
</table>
</form>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.