bschultz Posted July 22, 2010 Share Posted July 22, 2010 I have a search box on a site that searches the database for similar items. When you call the search page for the first time...everything works great. However, if you search FROM WITHIN the search page...it returns EVERY item in the database....not just those that match. In searching for solutions, I've seen that you can't unset a $_GET variable. I've tried unset($GLOBALS); and that didn't work either. Any ideas? Thanks. Link to comment https://forums.phpfreaks.com/topic/208492-unset-_get/ Share on other sites More sharing options...
kenrbnsn Posted July 22, 2010 Share Posted July 22, 2010 Code? Link to comment https://forums.phpfreaks.com/topic/208492-unset-_get/#findComment-1089382 Share on other sites More sharing options...
bschultz Posted July 22, 2010 Author Share Posted July 22, 2010 <?php $search_word = $_GET[keyword]; /////////////////////// SEARCH KEYWORDS HERE /////////////////////// $link = mysql_pconnect($host, $username, $password); mysql_select_db('northwoo_allconten',$link); $sql = "SELECT * FROM stories WHERE (station = 'mix' OR station = 'all') AND (headline LIKE '%$search_word%' OR long_story LIKE '%$search_word%')"; //$sql = "SELECT * FROM stories WHERE (station = 'mix' OR station = 'all') AND (headline LIKE '%$_GET[keyword]%')"; $rs = mysql_query($sql,$link); $matches = 0; echo "<h3>Here are the results of your search...</h3>"; while ($row = mysql_fetch_assoc($rs)) { $matches++; echo "<div class='left_box'>"; $headline = str_replace('COMPANYNAMEHERE',COMP_NAME,$row['headline']); echo "<h3>$headline</h3>"; echo "<div class='left_img_box'>$row[short_story_image]</div>"; echo "<div class='left_text_content'><p>"; $code2 = str_replace('COMPANYNAMEHERE',COMP_NAME,$row['short_story']); eval('?>' . $code2 . '<?'); echo "</p></div></div>"; } if (! $matches) { echo ("No matches for search term '$_GET[keyword]'...please try again.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />"); } echo ""; unset($GLOBALS); ?> Link to comment https://forums.phpfreaks.com/topic/208492-unset-_get/#findComment-1089383 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.