I'm trying to search for things in a table using LIKE. The query returns the correct number of results through PHP MyAdmin, but when I use the following PHP I only get 2. There should be four.
The table looks like this.
object_key
primary key
not null
object_name
text
not null
object_description
text
not null
Their are four rows with the object name set to honey crisp apple. The PHP My Admin query returns 4, PHP returns 2. Can anyone see why?
<?php
$my_id = "myid";
$my_pass = "mypass";
$my_db = "mydb";
$connect = mysql_connect('localhost', $my_id, $my_pass);
$select = mysql_select_db($my_db);
if(isset($_POST['submit'])){
$var_from_form_input ='%'.$_POST['var'];
if($select){
// FIND THE MATCHES
$match_query = "SELECT object_name FROM mytable WHERE object_name LIKE '$var_from_form_input'";
$result = mysql_query($match_query);
$result_rows = mysql_fetch_array($result);
$result_num = count($result_rows);
echo $result_num.' number of results<br/>';
echo $result_rows[0]';
}
}
?>
Thanks