Jump to content

Recommended Posts

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!
Link to comment
https://forums.phpfreaks.com/topic/33550-search-code-help-plz/
Share on other sites

try this.

[code]<?php
echo "                          <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]
Link to comment
https://forums.phpfreaks.com/topic/33550-search-code-help-plz/#findComment-157128
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/33550-search-code-help-plz/#findComment-157195
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.