Jump to content


Photo

*SOLVED* Navigating the Database


  • Please log in to reply
5 replies to this topic

#1 fizzzgigg

fizzzgigg
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 03 June 2006 - 09:05 PM

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

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 03 June 2006 - 10:52 PM

Can't see the problem with spaces

:: test.php ::
<?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>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 fizzzgigg

fizzzgigg
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 03 June 2006 - 11:41 PM

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.

#4 fizzzgigg

fizzzgigg
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 04 June 2006 - 03:05 AM

Here is the code on how the table is built.
<?
    
    $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>";


?>


#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 04 June 2006 - 04:14 AM

You should get into the habit of using quotes around the attribute values within tags.

// unquoted

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


// quoted

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

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#6 fizzzgigg

fizzzgigg
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 05 June 2006 - 12:36 AM

Oh your beautiful. Sorry about the quoute thing too.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users