Hello peeps!
I've got an issue which I am trying to sort out.
I am trying to build a website where ppl can search for car's sell and buy.
I got stack where I had to make the search option on the website, so I started looking on google where and how I can find solution on my problem so I found this webpage http://www.daniweb.com/web-development/php/threads/367225/filter-search-phpmysql .
I decided to use the code provided there so I can filter my search option and to finaly complete that, but after making some minor changes such as changing the database fields names and so on, now the code produces a error which says that the virable on line 51 is undefined and I can find out why... can you check it out for me please? As you can see from the issue of got I am not experienced with PHP at all, so would really appreaciate if you can help me out with this.
Here is the code I am talking about:
<?php
$connect = mysql_connect("localhost","root","8707056341") or die ('Error: '.mysql_error());
mysql_select_db("comparecars.co.uk"); //select database
if(isset($_GET['submit']) && !empty($_GET))
{
$where = "1 = 1";
if($_POST['search_make']!="") {
$s[] = "`make` like '%" . mysql_real_escape_string($_POST['search_make']) . "%'";
}
if($_POST['search_model']!="") {
$s[] = "`model` like '%" . mysql_real_escape_string($_POST['search_model']) . "%'";
}
if($_POST['minprice']!="" && $_POST['maxprice']!="") {
$s[] = "(`price` between " . intval($_POST['minprice']) ." AND ".intval($_POST['maxprice']) .")";
}
if($_POST['fuel']!="") {
$s[] = "`fueltype` like '%" . mysql_real_escape_string($_POST['fuel']) . "%'";
}
if($_POST['year1']!="" && $_POST['year2']!="") {
$s[] = "(`registration` between " . intval($_POST['year1']) ." AND ".intval($_POST['year2']) .")";
}
if($_POST['search_bodytype']!="") {
$s[] = "`bodytype` like '%" . mysql_real_escape_string($_POST['search_bodytype']) . "%'";
}
if($_POST['search_doors']!="") {
$s[] = "`doors` like '%" . mysql_real_escape_string($_POST['search_doors']) . "%'";
}
if($_POST['search_transmission']!="") {
$s[] = "`transmission` like '%" . mysql_real_escape_string($_POST['search_transmission']) . "%'";
}
if($_POST['search_enginesize']!="") {
$s[] = "`enginesize` like '%" . mysql_real_escape_string($_POST['search_enginesize']) . "%'";
}
if(isset($s)){
$where = "WHERE (" . implode(" AND ",$s).")";
}
}
$query_str = "SELECT * FROM offers {$where";
echo $query_str;
?>