UORHQ Posted May 14, 2011 Share Posted May 14, 2011 I'm trying to design a PHP search engine, everything works except the results being displayed and i can't find any problems in the script. Can someone else please look and see if there is something wrong <?php //get data $button = $_GET['submit']; $search = $_GET['search']; if (!$button) echo "You searched for <b>$search</b><hr/>"; else { if ($button) echo "You searched for <b>$search</b><hr/>"; else { //connect to our database mysql_connect("localhost", "392627", "password"); mysql_select_db("392627"); $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { $x++; if ($x==1) $construct .= "keywords LIKE `%$search_each%`"; else $construct .= "OR keywords LIKE `%$search_each%`"; } } $construct = "SELECT * FROM searchengine WHERE $construct"; $run = mysql_query($construct); $foundnum = mysql_num_rows($run); if ($foundnum==0) echo "<div align='center'>Sorry, No results found</div>"; else { echo "<div align='center'><b>$foundnum</b> Results found! Thanks for searching with us!</div><p>"; while ($runrows = mysql_fetch_assoc($run)) { //get data $title = $runrows['title']; $desc = $runrows['description']; $url = $runrows['url']; echo " <b>$title</b><br> $desc<br> <a href='$url'>$url</a><p> "; } } } ?> Quote Link to comment Share on other sites More sharing options...
markjoe Posted May 14, 2011 Share Posted May 14, 2011 for starters, always use { and } even for one line if/else blocks to make it easier for people to read. always post code here in code tags. and read the posting guidelines about titling your post and posting to the proper forum. ("code problem" is a terrible thread name, and this is not about a 3rd party script) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.