Very perplexed here...hopefully someone can shed some light on this.
I have a page with a search text box on it...I want the user to enter some text and then click the search button and return records.
I started with this....
1. on the Main Page I can echo the value passed in the URL
2. I pass that value to the php page and do a very simple return..I can display that same value as in number 1 above.
$searchvalue = $_GET['ItemValue']; echo $searchvalue; $searchs = get_results($searchvalue); echo ' Returning '.$searchs;
Function get_results($searchvalue){ $searchs = trim($searchvalue); return $searchs; }
I am now trying to use that value in a query to SELECT records...BUT I am not returning any
$searchs = get_results($searchvalue);
Function get_results($searchvalue){ $searchvalue = mysql_real_escape_string(htmlentities($searchvalue)); $searchs = array(); $search_query = mysql_query("SELECT `image_id`, `album_id`, `timestamp`, `ext`, `description`, `name` FROM `images` WHERE `description`=$searchvalue ORDER BY `description`"); While ($searchs_row = mysql_fetch_assoc($search_query)){ $searchs[] = array( 'id' => $searchs_row['image_id'], 'album' => $searchs_row['album_id'], 'timestamp' => $searchs_row['timestamp'], 'ext' => $searchs_row['ext'], 'desc' => $searchs_row['description'], 'imagename' => $searchs_row['name'] ); } return $searchs; }
Back in the main page...I always get 'There are no images' when I check for empty
<?php if (empty($searchs)){ echo 'There are no images'; }else{ foreach ($searchs as $search){ //echo 'hi'; ?>
FURTHER MORE:
If I hard code the above SELECT statement as such it works FINE....
$search_query = mysql_query("SELECT `image_id`, `album_id`, `timestamp`, `ext`, `description`, `name` FROM `images` WHERE `description`='HICKORY_RIDGE_TOWNHOME' ORDER BY `description`");
is the syntax incorrect in the SELECT STATEMENT????
Thanks