Jump to content

*SOLVED* Navigating the Database


fizzzgigg

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
Link to comment
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]
Link to comment
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]
Link to comment
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.