Child not displaying data from correct parent

Hi, everyone!
I’m relatively new to php, and am stuck on one issue. My index.php file displays a list of states, and displays those states correctly. Each of those states has an ‘p_id’ field that correspond to the alphabetized listing of states.
The database I’m using has a table that contains the following fields in the cat table: p_id (parent id), state (name of state), city, and id (child’s id, which resets for every new state).
This is the query I use for populating the states:

select distinct state, p_id from cat order by state asc

List_cities.php is the next page that displays after clicking on a state. Alabama is the first state alphabetically, so would be parent (p_id)=1. When I click on Alabama (or any other state), no cities are displayed. They are all listed in the cat table.

This is the query I use to display the cities:

select p_id, id, city, state from cat where p_id=[php]"’.$p_id.’"[/php] order by p_id, id

Any help would be greatly appreciated!
Thanks!

Actual way to use is :
[php]$p_id = 1;
$t = mysql_query(‘select p_id, id, city, state from cat where p_id="’.$p_id.’" order by p_id, id’);
[/php]

Is it how you used?

Sponsor our Newsletter | Privacy Policy | Terms of Service