what I'm trying to do is:- when someone enters a postcode from a HTML form, the query will check the first half of the post code and return all the entries that match.
<?php
$link = mysqli_connect("localhost", "root", "mypass123", "carpooling");
$location = mysqli_real_escape_string($link, $_REQUEST['location']);
$query="SELECT * FROM journeys WHERE substring(location='$location', 1, 4)";
$results = mysqli_query($link, $query);
print_r($results);
?>
I've tried to use half of the substring because the postcode will be 8 characters long anyway, and I just need the first 4 to find out what area they are in. I just get a white page whenever I run it, I know it won't display the results as a list but I just need it to return properly.
EDIT: Now I'm getting:-
mysqli_result Object ( [current_field] => 0 [field_count] => 7 [lengths] => [num_rows] => 1 [type] => 0 )
as the output, there should be 3 rows that match this, so it's not actually finding the values, any ideas?
Thank you!