Jump to content

Archived

This topic is now archived and is closed to further replies.

fizzzgigg

*SOLVED* Navigating the Database

Recommended Posts

I have a database that I am trying to be able to navigate. To keep it simple I will use the states and cities. When you goto the site it needs to show all fifty states and then when you click the state you want, it will goto the cities of the states. I have gotten this far. My new, latest, and biggest problem is that cities alot of time, are more than two words. So the link looks like bobsite.com/find.php?state=NY&city=new it needs to look like bobsite.com/find.php?state=NY&city=new york city. I understand not passing spaces.

Now here is the thing I have a huge database of about 350K rows, and they all have cities and states and then businesses. Each Business has its own unique ID; not each city. If you could click to the links above and have it list out all the businesses under New York City than it could easily be tranfered to that spefic business unique ID.


What are some options that I can do here?
one of my options was to build a separate table with just cities and states, and each city with have its unique id, and then use that id to fill in the holes to access the other table with the businesses. I just know there is another way.

If only I could use a space in the url... I would be done with this. I have it to where you type the zip code, but the problem there is you may not know the zip code to the city you are looking in.

Plus wont google's spider suck up my complete database if I have a links to each row?

Adam

Share this post


Link to post
Share on other sites
Can't see the problem with spaces

:: test.php ::
[code]<?php
     if (isset($_GET['city']))echo "<H1>{$_GET['city']}</H1>";
?>
<a href='?city=New York City'>NY</a>
<BR>
<a href='?city=Los Angeles'>CA</a>[/code]

Share this post


Link to post
Share on other sites
well when I run my mouse over the top it only shows the first word to the link. I also just checked the source and it does show the both words. When I put my mouse over the buttom it will just show the first word.

Share this post


Link to post
Share on other sites
Here is the code on how the table is built.
[code]
<?
    
    $result=mysql_query("SELECT DISTINCT city,state FROM church WHERE state='$state'");
    
    
    $i=0;
    
    while( $row=mysql_fetch_array($result) )
    {
        if($i>0)
        {
            echo "<tr valign=bottom>";
            echo "<td bgcolor=#2172A1 colspan=6><img src=img/blank.gif width=1 height=1></td>";
            echo "</tr>";
        }
        echo "<tr valign=center>";        
        echo "<td class=tabval><b><a href=findnew3.php?state=".$state."&city=".$row['city'].">".$row['city']."</a></b></td>";
        echo "<td class=tabval></td>";
        echo "</tr>";
        $i++;

    }

    echo "<tr valign=bottom>";
        echo "<td bgcolor=#2172A1 colspan=9><img src=img/blank.gif width=1 height=8></td>";
        echo "</tr>";


?>
[/code]

Share this post


Link to post
Share on other sites
You should get into the habit of using quotes around the attribute values within tags.

// unquoted

[code]<A href=findnew3.php?state=NY&city=New York City>Click</A>
                                      ^
                                      |
          url assumed to finish here--+[/code]


// quoted

[code]<A href='findnew3.php?state=NY&city=New York City'>Click</A>
                                                 ^
                                                 |
                     url assumed to finish here--+[/code]

Share this post


Link to post
Share on other sites

×

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.