-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
54 lines (47 loc) · 1.25 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("vehicle") or die(mysql_error());
if(isset($_POST['submit']))
{
$query = $_POST['query'];
?>
<html>
<head>
<title><?php echo $query;?></title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
$min_length = 1;
if(strlen($query) >= $min_length)
{
$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
echo "<table border='0' width='300' align='center' cellpadding='1' cellspacing='1'>";
echo "<tr align='center' bgcolor='#002C40' style='color:#FFF'>
<td height='35px' width='150px'>vehicleNumber</td> <td>OwnerName</td>
</tr>";
$raw_results =
mysql_query("SELECT * FROM vehicle_info WHERE (`vehicleNumber` LIKE '%".$query."%') OR (`vehicleNumber` LIKE '%".$query."%')");
if(mysql_num_rows($raw_results) > 0)
{
while($results = mysql_fetch_array($raw_results))
{
echo "<tr align='center' bgcolor='#0f7ea3'>
<td height='25px'>".$results['vehicleNumber']."</td> <td>".$results['name']."</td>
</tr>" ;
}
}
else{
echo "<tr align='center' bgcolor='#6C0000'>
<td colspan='2' height='25px'>No results</td><tr>";
echo "</table>";
}
}
else{
echo "Minimum length is ".$min_length;
}}
?>
<a href="index.html">Go back to homepage</a>
</body>
</html>