Ameslee Posted January 10, 2007 Share Posted January 10, 2007 Hope someone can help me, im not sure about the following code, can someone tell me if i am doing it right or i should add anything else in.[code]<a href = \"?search=$Employment\"> Employment </a> <br> <a href = \"?search=$Government\"> Government </a> <br> <a href = \"?search=$Training\"> Training </a> <br> <a href = \"?search=$Rehabilitation\"> Rehabilitation </a><br> <a href = \"?search=$Accomodation\"> Accommodation </a><br> <a href = \"?search=$SportandLeisure\"> Sport and Leisure </a><br> <a href = \"?search=$Information\"> Information </a> <br> <a href = \"?search=$PersonalSupport\"> Personal Support </a> <br> <a href = \"?search=$Education\">Education </a> <br> <a href = \"?search=$TransitiontoWork\"> Transition to Work </a> <br> <a href = \"?search=$CommunityParticipation\"> Community Participation </a><br> </p> <?php $hostname = localhost; $username = ; $password = ; $conn = mysql_connect($hostname, $username, $password) or die(mysql_error()); $connection = mysql_select_db("greenac_VORNExpo", $conn); $search = $_GET['search']; $sql = mysql_query("SELECT * FROM services WHERE category LIKE '$search"."%'") or die(mysql_error()); while ($row = mysql_fetch_array($sql)){ // display results echo "<br><a href=\"display_services.php?id=".$row['service2id']."\">" .$row['name']. "<br>"; } ?>[/code]thanks! Quote Link to comment https://forums.phpfreaks.com/topic/33550-search-code-help-plz/ Share on other sites More sharing options...
Jessica Posted January 10, 2007 Share Posted January 10, 2007 You don't have to escape quotes outside of PHP.What are you trying to do? If you're not sure if it's working, what isn't working that makes you think that? Quote Link to comment https://forums.phpfreaks.com/topic/33550-search-code-help-plz/#findComment-157114 Share on other sites More sharing options...
DarkendSoul Posted January 10, 2007 Share Posted January 10, 2007 try this.[code]<?phpecho " <a href = \"?search=$Employment\"> Employment </a> <br> <a href = \"?search=$Government\"> Government </a> <br> <a href = \"?search=$Training\"> Training </a> <br> <a href = \"?search=$Rehabilitation\"> Rehabilitation </a><br> <a href = \"?search=$Accomodation\"> Accommodation </a><br> <a href = \"?search=$SportandLeisure\"> Sport and Leisure </a><br> <a href = \"?search=$Information\"> Information </a> <br> <a href = \"?search=$PersonalSupport\"> Personal Support </a> <br> <a href = \"?search=$Education\">Education </a> <br> <a href = \"?search=$TransitiontoWork\"> Transition to Work </a> <br> <a href = \"?search=$CommunityParticipation\"> Community Participation </a><br> </p>";// unless above is a refrence of what you want your php to do. $hostname = localhost; $username = ; $password = ; $conn = mysql_connect($hostname, $username, $password) or die(mysql_error()); $connection = mysql_select_db("greenac_VORNExpo", $conn); $search = $_GET['search']; $sql = mysql_query("SELECT * FROM services WHERE category LIKE '{$search}%'") or die(mysql_error()); while ($row = mysql_fetch_array($sql)){ // display results echo "<br><a href=\"display_services.php?id=".$row['service2id']."\">" .$row['name']. "</a><br>";// added </a>. above } ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33550-search-code-help-plz/#findComment-157128 Share on other sites More sharing options...
Ameslee Posted January 10, 2007 Author Share Posted January 10, 2007 Ok it isnt working. what i want to happen, you click on one of the links, then it searches the table, goes to the specific field "category", sees if whatever was clicked is in that field then displays it. but what i have is definetely not right. coz its already displaying all the records so far even before clicking on a link, plz help me someone, its getting confusing.thanks Quote Link to comment https://forums.phpfreaks.com/topic/33550-search-code-help-plz/#findComment-157195 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.