I am still learning PHP & MySQL, and am trying to figure some things out. I created a database with "company profiles" in it. I have also programmed a page that will display a particular companies information based on their "id". I would like to arrange it so that people visiting the site can choose a state & city to see a list of companies which would then link to the company profile page.
Instead of having to add each city in HTML whenever someone wants me to add their city, I thought it could pull from the database. I am assuming that I should create a new table for cities & states & give each of them an "id" of some sort as well, but I do not know how to make sure that they are all tied together. For example, If I create a state table & a city table, then remove the city & state rows from the company profile table, how do I make sure that the page that displays the company profile information still shows the location?
Hopefully that isn't too much overexplanation. If the solution requires anything done in MySQL & not just PHP, I am using PHPMyAdmin, so I should be able to figure it out easily enough. Thanks for any help! Below is how I am currently pulling info from the company profile table for display:
<?php
$Host = "localhost";
$User = "getitdon_warzol";
$Password = "jemy45";
$DBName = "getitdon_testing";
$TableName = "company_profile";
$id = $_GET['id'];
$link = mysql_connect ($Host, $User, $Password);
$query = "SELECT * FROM $TableName WHERE id='$id'";
$select = mysql_select_db ($DBName);
$result = mysql_query ($query, $link) or die(mysql_error());
$row = mysql_fetch_assoc ($result);
?>