Page 1 of 1
Multi Drop Down Menu Query
Posted: Tue Jan 23, 2007 12:36 am
by victhour
hello guys,
im wondering if anyone can share their idea regarding how to perform a multi drop down query or any tutorials regarding with it.
like for an example: lets say from drop down1 is for the class room and for drop down2 is for the assigned teacher. upon submiting it will then display students name according to class room and the corresponding teacher assigned.
please help...
tanx in advanced.
vic.
Posted: Tue Jan 23, 2007 12:48 am
by Christopher
There was a thread in Code Critique recently that might be of interest to you:
viewtopic.php?t=60287
Posted: Tue Jan 23, 2007 2:29 am
by victhour
nice thread actually, but i think that's a little bit advanced for me
anyway here the code that im working on... but its not working. guez any problem please.
Code: Select all
<?php
require("../config.php");
include("../modlib.php");
if(isset($_POST['cmdSearch'])){
$loc_point = $_POST['mnuLocation'];
$sec_point = $_POST['mnuSection'];
session_start();
conn_db($host, $user, $pass, 'superdb');
$query = 'SELECT news_mas.mas_id, news_mas.location, news_mas.section, news_mas.lock, news_dtl.date, news_dtl.title FROM news_mas, news_dtl
WHERE news_mas.mas_id = news_dtl.dtl_id AND news_mas.location = '.$loc_point.' AND news_mas.section = '.$sec_point.' ORDER BY news_dtl.date';
$result = mysql_query($query) or die('Error: '.mysql_error());
if(!mysql_num_rows($result) > 0){
echo '<script type="text/javascript">alert("No Articles Found!..")</script>';
exit;
}
}
?>
<html>
<head>
<link href="../../balita.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background: #CCCC99;
margin: 0px;
}
-->
</style>
</head>
<body>
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<table width="450" border="0" cellpadding="0" cellspacing="0" style="border-bottom: solid 4px #999966;">
<tr bgcolor="#CCCCFF">
<td height="24" colspan="3" bgcolor=""><table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-bottom: solid 4px #999966;">
<tr>
<td width="40" height="20" class="capIt">Filter</td>
<td width="102"><select name="mnuLocation" id="mnuLocation" class="selval2">
<option value="0" selected>-- Location --</option>
<option value="1">Cag. de Oro</option>
<option value="2">Cebu</option>
<option value="3">Davao</option>
<option value="4">Gen. Santos</option>
</select></td>
<td width="97"><select name="mnuSection" id="mnuSection" class="selval2">
<option value="0" selected>-- Section --</option>
<option value="1">Balita</option>
<option value="2">Opinyon</option>
<option value="3">Kalingawan</option>
<option value="4">Sports</option>
</select></td>
<td width="45" class="capIt">Search</td>
<td width="84">
<input name="cmdSearch" type="image" src="../../images/action_go.gif" width="16" height="16" border="0" style="margin-top:3px"></td>
<td width="84" align="center">Delete All </td>
</tr>
</table></td>
</tr>
<?php
if(isset($_POST['cmdSearch'])){
while($ctr = mysql_fetch_array($result)){ //Begin While
$section = $ctr['section'];
$location = $ctr['location'];
switch($section){ // Begin Switch
case 1: $sec = 'Balita'; break;
case 2: $sec = 'Opinyon'; break;
case 3: $sec = 'Kalingawan'; break;
case 4: $sec = 'Sports'; break;
} // End Switch
switch($location){ // Begin Switch
case 1: $loc = 'CDO'; break;
case 2: $loc = 'CBU'; break;
case 3: $loc = 'DVO'; break;
case 4: $loc = 'GEN'; break;
} // End Switch
$_SESSION['article_id'] = $ctr['mas_id'];
if(is_null($ctr['lock']) || $ctr['lock'] == 0){ // ?>
<tr>
<td height="20" class="trbdr"><?php echo $loc.' - '.$sec.': '; ?><a href="view_article.php?article_id=<?= $ctr['mas_id']; ?>" target="_blank">
<?= filval(charslen(45, $ctr['title'])); ?>
</a> </td>
<td width="25" class="trbdr"><a href="../mod_update.php?article_id=<?= $ctr['mas_id']; ?>">Edit</a></td>
<td width="40" class="trbdr"><a href="del_script.php?article_id=<?= $ctr['mas_id']; ?>">Delete</a></td>
</tr>
<?php }elseif($ctr['lock'] == 1){ ?>
<tr>
<td height="20" class="trbdr"><?php echo $loc.' - '.$sec.': '.filval(charslen(45, $ctr['title'])); ?> </a> </td>
<td width="25" class="trbdr">Edit</td>
<td width="40" class="trbdr">Delete</td>
</tr>
<?php }
} // end while
free_mem($result);
}
?>
</table>
</form>
</body>
</html>
i hope my code is easy to understand...
Posted: Fri Jan 26, 2007 9:03 am
by victhour
i need some help here please...

Posted: Fri Jan 26, 2007 10:54 am
by Kieran Huggins
you'll likely want to use a mysql db and a query like "SELECT * FROM table WHERE room='{$room}' AND teacher='{$teacher}"
Posted: Wed Jan 31, 2007 11:30 pm
by victhour
can you look at my code above what went wrong...