Hey guys, How complicated is it to do this? I have a business listings database in mysql format, and I want to make a site from it. It's weight loss clinics, and I want the homepage to have a list of states, then if you click on a state it shows all clinics there, etc... How can I make a php script to do this? Any resources that would help me do so? My developer is bogged down with my other projects and I want to do this fast so let me know, thanks!!!!
Well if there is a column in the database called states then there will be a lot of work. But basically you just merge a $_GET[] string with a mysql_query, to show each states entries. Learn a bit how to do it by going here: http://www.tizag.com/mysqlTutorial/mysqlwhere.php
Just pass your state and city variables to something like this... <?php $db = mysql_connect("localhost", "youruser", "yourpass"); mysql_select_db("YourDBName",$db); $result17 = mysql_query("SELECT * FROM YourTableName WHERE City = '$city' AND State = '$state' "); $num_rows = mysql_num_rows($result17); while ($row = mysql_fetch_array($result17)) { $field1 = $row["Id"]; $field2 = $row["Keywords1"]; $field3 = $row["Keywords2"]; $field4 = $row["Name"]; $field5 = $row["Address"]; $field6 = $row["City"]; $field7 = $row["State"]; $field8 = $row["Zip"]; $field9 = $row["Telephone"]; $field10 = $row["Fax"]; $field11 = $row["Description"]; $field12 = $row["Contact"]; $field13 = $row["Web"]; $field14 = $row["Email"]; echo "<tr><td><font face=tahoma color=black size=1><b>$field4</b></td><td align=right><font face=tahoma color=#0000aa size=1><i>$field2</i></td></tr><tr><td><font face=tahoma color=black size=1> $field5 $field6, $field7 $field8</td><td align=right><font face=tahoma color=black size=1><b> $field9 </b></td></tr>\n"; } mysql_close(); ?> Code (markup): Of course you will need to edit your username, password and field names etc...
Hello, LivingEarth - thanks for the script. When you say I need to pass my city and state variables to that script, what does that require that I do? I don't even know this, sorry.
Save script in wordpad. Name it "clinics.php" or whatever works for you. Pass the variables in url links directly to its url for example... yoursite.com/clinics.php?city=Boston&state=MA Of course you need to set up your database on your server and edit the script to match it and the fields in your database..