Mr Chris Posted July 10, 2006 Share Posted July 10, 2006 Hi Guys,Still having a few problems with this searhscript that I builtI have a searchform which searches on two things:1) the ‘section’(nature) of a story ie news, sport, business etc2) Any searchstring text entered in a text boxNow say my search returned 3 results:- One Business Story- One Sports Story- One News StoryI want the <href> of the story to output to go to:…/sport/story.php?story_id='.$row['story_id'] – [B]For Sport results returned[/b]…/business/story.php?story_id='.$row['story_id'] – [B]For Business results returned[/b]…/news/story.php?story_id='.$row['story_id'] – [B]For News results returned[/b]But for each story the search return just outputs all results as:[b]../Resource id #3[/b] – just ignoring the if rules?Can anyone please help?[code=php:0]<?php /* ======== START FIRST FORM SEARCH ======== */ include("../****************");// Define Variable form 'First Query' post; $section = $_GET['section']; $searchstring = ($_GET['searchstring'] != "") ? $_GET['searchstring'] : false; if($searchstring === false){ die("No searchstring was entered!"); } if ($section == 'news') { $link = "../news/story.php?story_id=" . $row['story_id'];} else if ($storytype == 'sport') { $link = "../sport/story.php?story_id=" . $row['story_id'];} else if ($storytype == 'business') { $link = "../business/story.php?story_id=" . $row['story_id'];}$query=mysql_query("select *, DATE_FORMAT(appeared, '%W %e %M %Y') as formatted_date from cms_stories where section like '%$section%' AND ( headline LIKE '%$searchstring%' OR body_text LIKE '%$searchstring%' )") or die(mysql_error()); echo "<table width=\"100%\" border=0 bgcolor=\"#cccccc\" cellpadding=1 cellspacing=1>\n"; echo "<tr> <th><DIV ALIGN=\"LEFT\">Type of Story</div></th><th><DIV ALIGN=\"LEFT\">Appeared in Newspaper</div></th> <th><DIV ALIGN=\"LEFT\">Headline</div></th> <th><DIV ALIGN=\"LEFT\">Read Story</div></th> </tr>";while($rows = mysql_fetch_assoc($query)) { echo "<tr BGCOLOR=\"#FFFFFF\"><td>"; echo $rows['section']; echo "</td><td>"; echo $rows['formatted_date']; echo "</td><td>"; echo $rows['headline']; echo "</td><td>"; echo '<a href="' . $link . '">[ more ]</a>'; echo "</td></tr>"; }echo "</table>";/* ======== END FIRST FORM SEARCH ======== */ ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14163-searchscript-results-returned/ Share on other sites More sharing options...
kenrbnsn Posted July 10, 2006 Share Posted July 10, 2006 Where is the array $row coming from for these lines?[code]<?phpf ($section == 'news') { $link = "../news/story.php?story_id=" . $row['story_id'];} else if ($storytype == 'sport') { $link = "../sport/story.php?story_id=" . $row['story_id'];} else if ($storytype == 'business') { $link = "../business/story.php?story_id=" . $row['story_id'];}?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/14163-searchscript-results-returned/#findComment-55476 Share on other sites More sharing options...
Mr Chris Posted July 10, 2006 Author Share Posted July 10, 2006 Hi Ken,Whoops typo that should be $row[b]s[/b] as defined:[code]while($rows = mysql_fetch_assoc($query))[/code]..But still does this strange resource id message???Many Thanks Quote Link to comment https://forums.phpfreaks.com/topic/14163-searchscript-results-returned/#findComment-55490 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.