My last question hopefully )
My search results page at present grabs all the data, I want it to only bring back depending on what the user types into a search field, so I guess I need to use LIKE
So for my results counter...
But this gives me the error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on the last line in the above code.
For the main results section...
but this gives off loads of errors
If it makes it easier to see, here is the entire code
My search results page at present grabs all the data, I want it to only bring back depending on what the user types into a search field, so I guess I need to use LIKE
So for my results counter...
Code:
$query2 = "SELECT COUNT(*) as c FROM properties where city LIKE {$_GET['region_input_box']}";
$result2 = mysql_query($query2);
$returned = mysql_fetch_array($result2, MYSQL_ASSOC)
For the main results section...
Code:
//found out how many records in table in order to cut off when reach specified number
$query2=" SELECT * FROM properties where city LIKE {$_GET['region_input_box']} ";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
$query=" SELECT * FROM properties where city LIKE {$_GET['region_input_box']} limit $eu, $limit ";
$result=mysql_query($query);
echo mysql_error();
but this gives off loads of errors
If it makes it easier to see, here is the entire code
Code:
<?php
require "dbconn.php";
//grab the number of results for the field below
$query2 = "SELECT COUNT(*) as c FROM properties where city LIKE {$_GET['region_input_box']}";
$result2 = mysql_query($query2);
$returned = mysql_fetch_array($result2, MYSQL_ASSOC)
?>
There are <?php echo $returned['c'] ?> </span> results.
<?php
//paging
$page_name="search_results.php";
$start=$_GET['start'];
if(!($start > 0)) {
$start = 0;
}
$eu = ($start - 0);
if(!$limit > 0 ){ // if limit value is not available then let us use a default value
$limit = 4; // No of records to be shown per page by default.
}
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
//found out how many records in table in order to cut off when reach specified number
$query2=" SELECT * FROM properties ";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
$query=" SELECT * FROM properties limit $eu, $limit ";
$result=mysql_query($query);
echo mysql_error();
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
if($style=='search_result_even'){$style='search_result_odd';}
else{$style='search_result_even';}
echo "<div class='$style'>{$row['name']}";
}
?>
</div>
<?php
//display previous if there are previous
if($back >=0) {
print "< <a href='$page_name?start=$back&limit=$limit'>Previous properties</a> | ";
}
//display page numbers
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?start=$i&limit=$limit'>$l</a> ";
}
else { echo "<b>$l</b>";}
$l=$l+1;
}
//display next if there are next
if($this1 < $nume) {
print "| <a href='$page_name?start=$next&limit=$limit'>Next properties</a>";}
?>