Forum Moderators: open
mysql_connect('localhost', '', '') or die(mysql_error());
mysql_select_db("dwbrothe_plst1") or die(mysql_error());
$select = $_POST['select'];
if (!empty($select)) {
$chooser = $_POST['chooser'];
if(isset($_POST['chooser'])) {
$query = "SELECT COUNT(*) AS Total FROM phplist_user_user_attribute puua INNER JOIN phplist_listattr_visitor pllv ON puua.value = pllv.id WHERE pllv.id = $chooser";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while($row = mysql_fetch_assoc($result)){
foreach($row as $key => $value){
echo $key.': '.$value.'<br>';
}
echo '<br>';
}
}
}
?>
<form action="dropdown.php" method="post">
<select name="chooser">
<option value="2">Visitor</option>
<option value="3">Parent</option>
<option value="4">Student</option>
<option value="5">Alumni</option>
<option value="6">Sponsor</option>
</select>
<input type="submit" value="Select" name="select">
</form>
I would recommend using a framework to handle the AJAX calls. The Yahoo UI Library has it's Connection Manager [developer.yahoo.com] which is well documented. Essentially, what you'll want to do is add an onsubmit event listener to your form that will stop the event (preventing the default form submit from happening), and then using AJAX to submit the form data. You'll create a callback method that handles the output of the dropdown.php page, which you can then insert into your page. I know I've been a little vague, but I'm hoping that you'll be able to figure it out based on this suggestion. Let us know if you need more help.