Click link to show only that data from database

I want to create a link that will only show data with that is listed under a certain city

lets say that the link is showing the city “Madison”.

I want to show only the database information that has the city listed as “Madison”.

I have created a search box that will do this but I can’t figure out the hyperlink to do so

Here is the search box code…

The form

[code]

[/code]

[php]require ‘db.php’;

$city=$_GET[‘city’];

$sql = (“SELECT * FROM posting,state WHERE city=’$city’ ORDER BY posting_id DESC”);

$result = mysql_query($sql);

echo "//…You shouldn’t need the rest as this part works great[/php]

How do I go about getting the hyperlink to return the same result by just clicking the city?

hello,

so you retrieved data just fine all you need help is displaying the data as a hyperlink, correct?

also can show me an example of how the data show be displayed as hyperlink

Yes data that is displayed fine

Essentially all I want to do is take the search box and make it into a hyperlink

The user will see

Madison
Middleton
Monona
etc…

The code behind that will be
[php]<?php require ‘db.php’;
$sql = “SELECT * FROM posting”;
$result = mysql_query($sql);

while($row=mysql_fetch_array($result)){
echo “

  • <a href='listingsPage.php?”.$row[‘city’]."’>".$row[‘city’]."
  • ";
    }
    ?>
    [/php]

    I can’t figure out how to change the hyperlink/ $sql statement to return only the results I want

    I think I may have figured it out

    it looks as follows…

    [php]<?php
    require ‘db.php’;

    $sql1 = “SELECT city FROM city”;
    $result1 = mysql_query($sql1);

    while($row1=mysql_fetch_array($result1)){
      echo ("
         <li><a href='listingsPage.php?city=".$row1['city']."'>".$row1['city']."</a></li>
    ");
    

    };
    ?>[/php]

    cool

    i will mark this thread solved then

    Sponsor our Newsletter | Privacy Policy | Terms of Service