I need a dynamic dependent dropdown filter status along with size so that when select option in size the options should be displayed in the status dropdown and when click on it the perticular result to be displayed. below is my code and i need to have another filter and please provide me the answer.
<?php
/*
* Testing configuration
*/
define('ENVIR',0);
define('ENVIR_DEV',0);
define('ENVIR_LIVE',1);

/*
* Data base credentials (replace this with your db credentials)
*/
define('DB_USER','root');
define('DB_PWD','');
define('DB_HOST','localhost');
define('DB_NAME','test');

/*
* Connect to database
*/
try {
$db = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME,DB_USER,DB_PWD);
} catch(PDOExeption $e) {

if(ENVIR == ENVIR_DEV) {
echo '<p>',$e->getMessage(),'</p>';
}

echo '<p>Unable to connect to database<p>';
exit;
}

/*
* Template variables
*/
$tpl = array(
'filter'=>array(
'#action' => $_SERVER['SCRIPT_NAME']
,'#method' => 'get'
,'size' => array(
'#values'=>array(
array('value'=>'','label'=>'All')
)
)
)
,'grid'=>array(
'shasta'=>array()
)
);

/*
* Populate form filter last name options
*/
$stmt = $db->query('SELECT size FROM shasta GROUP BY size ORDER BY size ASC');

if($stmt === false) {
echo '<p>Unable to populate required data to build page.</p>';
exit;
}

while($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
$tpl['filter']['size']['#values'][] = array(
'label' => $row['size']
,'value' => $row['size']
,'selected' => isset($_GET['filter'],$_GET['filter']['size']) && $_GET['filter']['size'] == $row['size']
);
}


/*
* Populate user grid
*/
$stmt = $db->prepare(sprintf(
'SELECT sno,area,size,status FROM shasta %s'
, isset($_GET['filter'],$_GET['filter']['size']) && !empty($_GET['filter']['size'])?'WHERE size = :size':''
));

if($stmt === false) {
echo '<p>Unable to populate required data to build page.</p>';
exit;
}

$stmt->execute(isset($_GET['filter'],$_GET['filter']['size']) && !empty($_GET['filter']['size'])?array(':size'=>$_GET['filter']['size']):array());

while($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
$tpl['grid']['shasta'][] = $row;
}

/*
* Start template output
*/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Names</title>
</head>
<body>

<!-- user filter template -->
<form action="<?php echo $tpl['filter']['#action']; ?>" method="<?php echo $tpl['filter']['#method']; ?>">

<ul>
<li>
<label for="filter-last-name">Size</label>

<select name="filter[size]" id="filter-last-name">
<?php
foreach($tpl['filter']['size']['#values'] as &$option) {
printf(
'<option value="%s"%s>%s</option>'
,htmlentities($option['value'])
,$option['selected']?' selected':''
,htmlentities($option['label'])
);
}
?>
</select>

<input type="submit" name="filter[submit]" value="Show">


</li>



</ul>

</form>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="4"><strong>List data from mysql </strong> </td>
</tr>

<tr>
<td align="center"><strong>Sno</strong></td>
<td align="center"><strong>Area</strong></td>
<td align="center"><strong>Size</strong></td>
<td align="center"><strong>Status</strong></td>

</tr>
<tbody>
<?php
if(!empty($tpl['grid']['shasta'])) {
foreach($tpl['grid']['shasta'] as &$name) {
printf(
'<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>

</tr>'
,htmlentities($name['sno'])
,htmlentities($name['area'])
,htmlentities($name['size'])
,htmlentities($name['status'])
);
}
} else {
echo '<tr><td colspan="4">No names available</td></tr>';
}
?>
</tbody>


</table>
</td>
</tr>
</table>
<!-- data grid template -->


</body>
</html>[/HTML]