php - Select and show states and respective cities from MySQL table -
i have sql table 2 fields: city , state. build simple list of states , respective cities, until not. this:
<ul> <li>new york <ul> <li>albany</li> <li>buffalo</li> <li>new york city</li> </ul> </li> <li>illinois <ul> <li>chicago</li> <li>rockford</li> </ul> </li> </ul>
i did below select, list states. can't find way show respective cities:
<?php $result = mysqli_query($con,"select distinct states,cities table order states"); while($row = mysqli_fetch_array($result)) { // show here } ?>
states be
$row['states']
cities
$row['cities']
Comments
Post a Comment