Table_sup |
+-------------------+
| supid=>int |
| scompany=>varchar |
| sstate=>varchar |
| scity=>varchar |
| scat=>varchar |
PHP Code
<?php
include "db_connect.php"; // including configuration file
?>
<form name="frmdropdown" method="post" action="sample.php">
<center>
<h2 align="center">Select State</h2>
<strong> Select State : </strong>
<select name="getData">
<option value="">ALL--(<?php echo "" . $totalusa;?>) </option>
<?php
$dd_res=mysqli_query($con,"Select DISTINCT sstate, count(sstate) AS state from sup GROUP BY sup.sstate");
while($r=mysqli_fetch_row($dd_res))
{ echo "<option value='$r[0]'> $r[0]</option>";
}
?>
</select>
<input type="submit" name="Select" value="Select"/>
<br><hr>
Result I get
Select State
-------------
| ALL |
| CA |
| CO |
| FL |
| GA |
What I want
Select State
+-------------------+
| ALL |
| CA (472) |
| CO (7) |
| FL (5) |
| GA (45) |
Like this.each state in dropdown I want total counts of records in each state