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.
Multi Drop Down Menu Query
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
There was a thread in Code Critique recently that might be of interest to you:
viewtopic.php?t=60287
viewtopic.php?t=60287
(#10850)
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.
i hope my code is easy to understand...
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>- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact: