/    Sign up×
Community /Pin to ProfileBookmark

How to fetch data from database using a drop down menu

I have a drop down menu and would like to make each of the sub-menu in the drop down menu be dynamic. Which mean that each sub-menu allow to fetch data from the database and display out the data in a table. How can i fetch the data from database by using each of the sub-menu in the drop down menu in php and mysql? Can someone please help me out? I’m a beginner in PHP and SQL ? ? ?

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@blue-eye-labsDec 14.2007 — I'm not quite sure what you mean, do you want the submenu items to be fetched from the database or do you want the submenu items to fetch something from the database and then display it on the page dynamically?

For the first option, where you want a menu to be controlled by a database, you would have something like this:
[code=php]

<!--have all the headers etc up here -->

<?php

//connect to the database
$server = "localhost"; //your mysql server address
$usr = "username"; //your server user name
$pwd = "123password"; //your server password

$con = mysql_connect($server, $usr, $pwd); //connects to the database server
mysql_select_db("database"); //selects the database

$sql = "SELECT * FROM menuitems ORDER BY name DESC"; /*define the sql query so that you are selecting everything from a database called "menuitems" and ordering the rows by their "name" column in descending order*/
$result = mysql_query($sql); //this queries the database

$i = 1; //defines a number which we will make increase for every row

while($row = mysql_fetch_array($result) {
echo "<div id='menuitem" . $i . "'><a href='" . $row['link'] . "'>'" . $row['name'] . "'</a></div>";
$i++; //increase $i by one
}
/*what this part did was it fetched the first row from the query and put it's columns into an array (I used columns called "name" and "link" in this example). It then echos some html with the attributes for each record put into the <a> tags. After it has done that, it increases the variable $i by one and continues to fetch the next row of the database. Once it has processed all the rows, the php script ends*/

?>
<!-- have all the rest of your page here -->
[/code]


For the other option, you will probably have to use ajax or something, but I hope that this has helped.
Copy linkTweet thisAlerts:
@celest91authorDec 15.2007 — Thanks for the help on the 1st option. What i mean in my question is the second option. I wan the sub-menu to fetch data from database and display it, but the problem is with multiple sub-menu how can i fetch the data? Below is my code that i did.

This is : - search.php

<? include ("include/header.php"); ?>

<? include ("include/dbconnect_display.php"); ?>

<? include ("include/dbconnect_search.php"); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<link href="css/form_style.css" rel="stylesheet" type="text/css" />

</head>

<body><center><div id="displayentry">

<form method="post">

<table width="477" border="0">

<tr>

<td width="152" class="text">Search By Type</td>

<td width="10">:</td>

<td width="208"><select name="select" id="select">

<option value="choice" selected="selected">---Type Of Services---</option>

<option value="CB" >

<? $list=mysql_query("SELECT * FROM entry WHERE type_service_1 = 'Change Battery'");?>

CB</option>

<option value="UP">

<? $list=mysql_query("SELECT *
FROM entry WHERE type_service_2 = 'Update'");?>

UP</option>

<option value="RE">

<? $list=mysql_query("SELECT * FROM entry WHERE type_service_3 = 'Re-Programe'");?>

RE</option>

<option value="SV">

<? $list=mysql_query("SELECT *
FROM entry WHERE type_service_4 = 'Service'");?>

SV</option>

<option value="KE">

<? $list=mysql_query("SELECT * FROM entry WHERE type_service_5 = 'Keycard Error'");?>

KE</option>

<option value="SR">

<? $list=mysql_query("SELECT *
FROM entry WHERE type_service_6 = 'Small Ring'");?>

SR</option>

<option value="BR">

<? $list=mysql_query("SELECT * FROM entry WHERE type_service_7 = 'Big Ring'");?>

BR</option>

<option value="DL">

<? $list=mysql_query("SELECT *
FROM entry WHERE type_service_8 = 'Dead Lock'");?>

DL</option>

<option value="RD">

<? $list=mysql_query("SELECT * FROM entry WHERE type_service_9 = 'PBC Reader'");?>

RD</option>

<option value="CK">

<? $list=mysql_query("SELECT *
FROM entry WHERE type_service_10 = 'Checking'");?>

CK</option>

</select></td>

<td width="89"><input type="submit" name="button" id="button" value="Submit" /></td>

</tr>

</table>

</form>

<?

//echo "<span class='style2'> ";

echo "<table border="1" align="center">";

echo "<tr><td>Block Name</td>".

"<td>Room No</td>".

"<td>Date</td>".

"<td>Time</td>".

"<td>Type Of Service</td>".

"<td>Status</td>".

"<td>Remark</td>".

"</tr>";

"<tr><td>CB</td>".

"<td>UP</td>".

"<td>RE</td>".

"<td>SV</td>".

"<td>KE</td>".

"<td>SR</td>".

"<td>BR</td>".

"<td>DL</td>".

"<td>RD</td>".

"<td>CK</td>".

"</tr>";

while($row = mysql_fetch_array($list)){

?>

<tr>

<td>&nbsp;<? echo $row['block_no']; ?> </td>

<td>&nbsp;<? echo $row['room_no'];?> </td>

<td>&nbsp;<? echo $row['date_time'];?> </td>

<td>&nbsp;<? echo $row['time1'];?> </td>

<td>&nbsp;<? echo $row['type_service_1'];?> </td>

<td>&nbsp;<? echo $row['type_service_2'];?> </td>

<td>&nbsp;<? echo $row['type_service_3'];?> </td>

<td>&nbsp;<? echo $row['type_service_4'];?> </td>

<td>&nbsp;<? echo $row['type_service_5'];?> </td>

<td>&nbsp;<? echo $row['type_service_6'];?> </td>

<td>&nbsp;<? echo $row['type_service_7'];?> </td>

<td>&nbsp;<? echo $row['type_service_8'];?> </td>

<td>&nbsp;<? echo $row['type_service_9'];?> </td>

<td>&nbsp;<? echo $row['type_service_10'];?> </td>

<td>&nbsp;<? echo $row['status'];?> </td>

<td>&nbsp;<? echo $row['remark'];?> </td>

</tr>

<?

}

echo "</table>";

?>

</div>

</center>

</body>

</html>

<? include ("include/footer.php"); ?>
Copy linkTweet thisAlerts:
@blue-eye-labsDec 15.2007 — what I don't really understand is when you say: WHERE type_service_1 =...[/QUOTE] and then WHERE type_service_2 =...[/QUOTE].

Why are you using different columns for this?

If you want to use a menu list to select data to display on a page, then you could do something like this (also you can't really do that where clause I don't think (ie with the massive php gap with some in between.. if you can then I am mistaken):

[code=php]
<?php $this = "path/to/this.document"; ?>

<script language='javascript' type='text/javascript'>
function changeLoc(value) {
newLoc = window.location + "&amp;do=display&amp;item=" + value;
window.location.href = newLoc;
}
</script>

<?php

$con = mysql_connect("server", "usr", "pwd");
mysql_select_db("database");

$do = $_GET['do'];

switch($do) {

case display:

/*add the table and all in here.*/

break;

default:
$sql = "SELECT * FROM menu WHERE.......";
$result = mysql_query($sql);

echo "<form action='" . $this . "' method='get'>
<select name='menu' onclick='changeLoc(this.value)'>";

while($row = mysql_fetch_array($result)) {

echo "<option value='" . $row['value'] . "'>" . $row['name'] . "</option>";

}

echo "</select></form>";
break;
}

?>
[/code]


I'm not sure if that's actually what you want, but I hope it helps a bit.
Copy linkTweet thisAlerts:
@celest91authorDec 22.2007 — I have found the way to fetch my data using a drop menu by using this method. Im not sure its good method, but it seems that i can query my data from database through my drop down menu.

Here is the source code,
<? include ("include/header.php"); ?>

<? include ("include/dbconnect_display.php"); ?>

<? include ("include/dbconnect_search.php"); ?>

<html>

<link href="css/form_style.css" rel="stylesheet" type="text/css">

<body><center><div id="displayentry">

<?

if($_POST['block'] == "search.php?select=1")

{

$_
POST['block'] = '1A';

}

elseif($_POST['block'] == "search.php?select=2")

{

$_
POST['block'] = '1B';

}

elseif($_POST['block'] == "search.php?select=3")

{

$_
POST['block'] = '2A';

}

elseif($_POST['block'] == "search.php?select=4")

{

$_
POST['block'] = '2B';

}

elseif($_POST['block'] == "search.php?select=5")

{

$_
POST['block'] = '3A';

}

elseif($_POST['block'] == "search.php?select=6")

{

$_
POST['block'] = '3B';

}

elseif($_POST['block'] == "search.php?select=7")

{

$_
POST['block'] = '4A';

}

elseif($_POST['block'] == "search.php?select=8")

{

$_
POST['block'] = '4B';

}

elseif($_POST['block'] == "search.php?select=9")

{

$_
POST['block'] = '5A';

}

elseif($_POST['block'] == "search.php?select=10")

{

$_
POST['block'] = '5B';

}

elseif($_POST['block'] == "search.php?select=11")

{

$_
POST['block'] = '6A';

}

elseif($_POST['block'] == "search.php?select=12")

{

$_
POST['block'] = '6B';

}

elseif($_POST['block'] == "search.php?select=13")

{

$_
POST['block'] = '7A';

}

elseif($_POST['block'] == "search.php?select=14")

{

$_
POST['block'] = '7B';

}

elseif($_POST['block'] == "search.php?select=15")

{

$_
POST['block'] = '8A';

}

elseif($_POST['block'] == "search.php?select=16")

{

$_
POST['block'] = '8B';

}

elseif($_POST['block'] == "search.php?select=17")

{

$_
POST['block'] = '8C';

}

elseif($_POST['block'] == "search.php?select=18")

{

$_
POST['block'] = '8D';

}

elseif($_POST['block'] == "search.php?select=19")

{

$_
POST['block'] = '8E';

}

elseif($_POST['block'] == "search.php?select=20")

{

$_
POST['block'] = '9A';

}

elseif($_POST['block'] == "search.php?select=21")

{

$block = '9B';

}

elseif($_
POST['block'] == "search.php?select=View All")

{

$block = 'View All';

}

echo $block;

echo $room = $_POST['select'];

echo $date = $_
POST['dc'];

echo $service = $_POST['type'];

$list = mysql_query("SELECT * FROM entry WHERE date_time = '$date' ORDER BY room_no");
?>

<?

echo "<table width="1050" border="1" align="center" bordercolor="#999999">";

echo "<tr>";

echo "<td rowspan="2" valign="middle" bgcolor="#FFFFFF" class="title"><div align="center">Block Name</div></td>";

echo "<td rowspan="2" valign="middle" bgcolor="#FFFFFF" class="title"><div align="center">Room No</div></td>";

echo "<td rowspan="2" valign="middle" bgcolor="#FFFFFF" class="title"><div align="center">Date</div></td>";

echo "<td rowspan="2" valign="middle" bgcolor="#FFFFFF" class="title"><div align="center">Time</div></td>";

echo "<td colspan="10" bgcolor="#FFFFFF" class="title"><div align="center">Type of Service</div></td>";

echo "<td rowspan="2" valign="middle" bgcolor="#FFFFFF" ><div align="center" class="title">Status</div></td>";

echo "<td rowspan="2" valign="middle" bgcolor="#FFFFFF" class="title"><div align="center">Remark</div></td>";

echo "</tr>";

echo "<tr>";

echo "<td bgcolor="#FFFFFF" class="text"><div align="center"><span class="text">CB</span></div></td>";

echo "<td bgcolor="#FFFFFF" class="text"><div align="center"><span class="text">UP</span></div></td>";

echo "<td bgcolor="#FFFFFF" class="text"><div align="center"><span class="text">RE</span></div></td>";

echo "<td bgcolor="#FFFFFF" class="text"><div align="center"><span class="text">SV</span></div></td>";

echo "<td bgcolor="#FFFFFF" class="text"><div align="center"><span class="text">KE</span></div></td>";

echo "<td bgcolor="#FFFFFF" class="text"><div align="center"><span class="text">SR</span></div></td>";

echo "<td bgcolor="#FFFFFF" class="text"><div align="center"><span class="text">BR</span></div></td>";

echo "<td bgcolor="#FFFFFF" class="text"><div align="center"><span class="text">DL</span></div></td>";

echo "<td bgcolor="#FFFFFF" class="text"><div align="center"><span class="text">RD</span></div></td>";

echo "<td bgcolor="#FFFFFF" class="text"><div align="center"><span class="text">CK</span></div></td>";

echo "</tr>";

// Show records by while loop.
while($row_list=mysql_fetch_assoc($list)){

?>

<tr>

<td width="100" bgcolor="#FFFFFF" class="text" align="center"><? echo $row_list['block_no']." "; ?></td>

<td width="75" bgcolor="#FFFFFF" class="text" align="center"><? echo $row_list['room_no']." "; ?></td>

<td width="103" bgcolor="#FFFFFF" class="text" align="center"><? echo $row_list['date_time']." "; ?></td>

<td width="80" bgcolor="#FFFFFF" class="text" align="center"><? echo $row_list['time1']." "; ?></td>

<td width="50" bgcolor="#FFFFFF" class="text" align="center"><? if ($row_list['type_service_1'] == 'Yes'){ ?> <img src="images/check.jpg" width="25" height="27"> <? } ?></td>

<td width="50" bgcolor="#FFFFFF" class="text" align="center"><? if ($row_list['type_service_2'] == 'Yes'){ ?> <img src="images/check.jpg" width="25" height="27"> <? } ?></td>

<td width="50" bgcolor="#FFFFFF" class="text" align="center"><? if ($row_list['type_service_3'] == 'Yes'){ ?> <img src="images/check.jpg" width="25" height="27"> <? } ?></td>

<td width="50" bgcolor="#FFFFFF" class="text" align="center"><? if ($row_list['type_service_4'] == 'Yes'){ ?> <img src="images/check.jpg" width="25" height="27"> <? } ?></td>

<td width="50" bgcolor="#FFFFFF" class="text" align="center"><? if ($row_list['type_service_5'] == 'Yes'){ ?> <img src="images/check.jpg" width="25" height="27"> <? } ?></td>

<td width="50" bgcolor="#FFFFFF" class="text" align="center"><? if ($row_list['type_service_6'] == 'Yes'){ ?> <img src="images/check.jpg" width="25" height="27"> <? } ?></td>

<td width="50" bgcolor="#FFFFFF" class="text" align="center"><? if ($row_list['type_service_7'] == 'Yes'){ ?> <img src="images/check.jpg" width="25" height="27"> <? } ?></td>

<td width="50" bgcolor="#FFFFFF" class="text" align="center"><? if ($row_list['type_service_8'] == 'Yes'){ ?> <img src="images/check.jpg" width="25" height="27"> <? } ?></td>

<td width="50" bgcolor="#FFFFFF" class="text" align="center"><? if ($row_list['type_service_9'] == 'Yes'){ ?> <img src="images/check.jpg" width="25" height="27"> <? } ?></td>

<td width="50" bgcolor="#FFFFFF" class="text" align="center"><? if ($row_list['type_service_10'] == 'Yes'){ ?> <img src="images/check.jpg" width="25" height="27"> <? } ?></td>

<td width="71" bgcolor="#FFFFFF" class="text" align="center"><? echo $row_list['status']." "; ?></td>

<td width="200" bgcolor="#FFFFFF" class="text"align="center"><? echo $row_list['remark']." "; ?></td>

</tr>

<p>

<?

}

echo "</table>";

?>

</p>

</div>

</center>

</body>

</html>

<? include ("include/footer.php"); ?>[/QUOTE]
Copy linkTweet thisAlerts:
@blue-eye-labsDec 22.2007 — I have to go out now, and will look at it in more depth in a bit, but I noticed that you are using a huge amount of if elseif clauses; these are unnecessary, use a switch statement instead, you also can't change the value of the $_POST[] bit, so do this:

[code=php]
<?php
$block = $_POST['block'];

switch($block) {

case 1:
$block = "1A";
break;

case 2:
$block = "2A";
break;

case n:
$block = "whatever";
break;

default:
echo "You haven't selected anything!";

}
//etc

[/code]

Basically a switch($variable) {} statement replaces lots of if... elseif ... else statements.

What it says is that "case x:" means that "if the variable has the value x then..." and you use a "break;" statement to end that case. You must then specify the default case if the variable doesn't satisfy any of the cases.

When using this, I noticed that you've said "if($block == 'search.php?select=1') {}" etc. This is unlikely to be the case.

If a URL is "page.php?variable=x" then [code=php]echo $_GET['variable'];[/code] will echo x[/quote].

The post method doesn't show the variables in the URL, so if a form looks like so:
[code=html]
<form action='search.php' method='post'>
<input type='text' name='textbox' />
<button type='submit' value='submit' name='subButton'>Submit</button>
</form>
[/code]
And into the input text box you enter "hello world", and use the search.php to get the posted variable, you'll get this:
[code=php]
<?php
$text = $_POST['textbox'];
echo "You searched for '" . $text . "'!";
?>
[/code]

The output returned to you would be:


You searched for 'hello world'!
[/quote]

As I said, I will return.
Copy linkTweet thisAlerts:
@celest91authorDec 24.2007 — You did mention in your previous reply about I noticed that you've said "if($block == 'search.php?select=1') {}" etc[/QUOTE] This code i used in my searching selection.
if($select == 1)[/QUOTE]
Will help me to display a drop down menu that show the room list which i will retrieved from my database table name block. Hope you can understand what i mean. As for your suggestion, instead of using Ifelse change to switch(case) function. I found it more easily understood but with the "($select == 1)" can i implement the switch(case) function too?

*will attach u the my search option code in next reply post.

Thanks for coming back for my prob.

Seasons Greetings to you....?
Copy linkTweet thisAlerts:
@celest91authorDec 24.2007 — This is my searching selection options: [code=php]<? include ("include/header.php"); ?>
<? include ("include/dbconnect_display.php"); ?>
<? include ("include/dbconnect_search.php"); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/form_style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
</style>
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>

<?
$select = $_GET['select'];
?>
</head>
<body>
<div id="displayentry">
<form id="demoform" name="demoform" method="post" action="display.php" >
<table width="895" border="0" align="center" cellspacing="1" >
<tr>
<td width="111" bordercolor="#666666" class="text"><div align="right">Block Selection:</div></td>
<td width="262" bordercolor="#666666" class="text"><span class="text style1">
<select name="block" id="block" size="1" onchange="MM_jumpMenu('parent', this, 1)">
<?
?>
<option>Select Block From List Below </option>
<option value="search.php?select=View All"<? if ($select == 'View All') {?> selected="selected" <? }?>> View All </option>
<option value="search.php?select=1"<? if ($select ==1) {?> selected="selected" <? }?> > Block 1 - Nibong - First Floor</option>
<option value="search.php?select=2"<? if ($select ==2) {?> selected="selected" <? }?> >Block 1 - Nibong - Second Floor </option>
<option value="search.php?select=3"<? if ($select ==3) {?> selected="selected" <? }?> >Block 2 - Menggaris - First Floor </option>
<option value="search.php?select=4"<? if ($select ==4) {?> selected="selected" <? }?> >Block 2 - Menggaris - Second Floor </option>
<option value="search.php?select=5"<? if ($select ==5) {?> selected="selected" <? }?> >Block 3 - Angsana - First Floor</option>
<option value="search.php?select=6"<? if ($select ==6) {?> selected="selected" <? }?> >Block 3 - Angsana - Second Floor</option>
<option value="search.php?select=7"<? if ($select ==7) {?> selected="selected" <? }?> >Block 4 - Beringin - First Floor </option>
<option value="search.php?select=8"<? if ($select ==8) {?> selected="selected" <? }?> >Block 4 - Beringin - Second Floor </option>
<option value="search.php?select=9"<? if ($select ==9) {?> selected="selected" <? }?> >Block 5 - Merawan - First Floor</option>
<option value="search.php?select=10"<? if ($select ==10) {?> selected="selected" <? }?> >Block 5 - Merawan - Second Floor</option>
<option value="search.php?select=11"<? if ($select ==11) {?> selected="selected" <? }?> >Block 6 - Cemara - First Floor</option>
<option value="search.php?select=12"<? if ($select ==12) {?> selected="selected" <? }?> >Block 6 - Cemara - Second Floor</option>
<option value="search.php?select=13"<? if ($select ==13) {?> selected="selected" <? }?> >Block 7 - Tembusu - First Floor</option>
<option value="search.php?select=14"<? if ($select ==14) {?> selected="selected" <? }?> >Block 7 - Tembusu - Second Floor</option>
<option value="search.php?select=15"<? if ($select ==15) {?> selected="selected" <? }?> >Block 8 - Ocean Wing - 1st Floor</option>
<option value="search.php?select=16"<? if ($select ==16) {?> selected="selected" <? }?> >Block 8 - Ocean Wing - 2nd Floor</option>
<option value="search.php?select=17"<? if ($select ==17) {?> selected="selected" <? }?> >Block 8 - Ocean Wing - 3rd Floor</option>
<option value="search.php?select=18"<? if ($select ==18) {?> selected="selected" <? }?> >Block 8 - Ocean Wing - 4th Floor</option>
<option value="search.php?select=19"<? if ($select ==19) {?> selected="selected" <? }?> >Block 8 - Ocean Wing - 5th Floor</option>
<option value="search.php?select=20"<? if ($select ==20) {?> selected="selected" <? }?> >Presidential Villa</option>
<option value="search.php?select=21"<? if ($select ==21) {?> selected="selected" <? }?> >Royal Villa</option>
</select>
</span></td>
<td width="105" bordercolor="#666666" class="text">Search By Date :</td>
<td width="150" bordercolor="#666666" class="text"><a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fPopCalendar(document.demoform.dc);return false;" >
<input name="dc" value="" size="11" />
<img class="PopcalTrigger" align="absmiddle" src="HelloWorld/calbtn.gif" width="34" height="22" border="0" alt="" /></a></td>
<td width="99" bordercolor="#666666" class="text">Search By Type:</td>
<td width="149" bordercolor="#666666" class="text"><select name="type" >
</td>
</tr>
<tr>
<td bordercolor="#666666" class="text"><div align="right">Room No.</div></td>
<td bordercolor="#666666" class="text"><?
if($select == 1)
{
?>
<select name="select" id="select">
<option>---Select Room---</option>
<option> View All </option>
<?
// Get records from database (table "name_list").
$list=mysql_query("SELECT * FROM block WHERE block_no = 1 && floor =1");

// Show records by while loop.
while($row_list=mysql_fetch_assoc($list)){
?>
<option value="<? echo $row_list['room_no']; ?>"><? echo $row_list['room_no']; ?></option>
<?
// End while loop.
}
?>
</select>
<?
}
elseif($select == 2)
{
?>

<select name="select" id="select">
<option>---Select Room---</option>
<option> View All </option>
<?
// Get records from database (table "name_list").
$list=mysql_query("SELECT * FROM block WHERE block_no = 1 && floor = 2");

// Show records by while loop.
while($row_list=mysql_fetch_assoc($list)){
?>
<option value="<? echo $row_list['room_no']; ?>"><? echo $row_list['room_no']; ?></option>
<?
// End while loop.
}
?>
</select>
<?
}
elseif($select == 3)
{
?>
<select name="select" id="select">
<option>---Select Room---</option>
<option> View All </option>
<?
// Get records from database (table "name_list").
$list=mysql_query("SELECT * FROM block WHERE block_no = 2 && floor = 1");

// Show records by while loop.
while($row_list=mysql_fetch_assoc($list)){
?>
<option value="<? echo $row_list['room_no']; ?>"><? echo $row_list['room_no']; ?></option>
<?
// End while loop.
}
?>
</select>
<?
}
.... so on and so fort til
elseif($select == 21)
{
?>
<select name="select" id="select">
<option>---Select Room---</option>
<option> View All </option>
<?
// Get records from database (table "block").
$list=mysql_query("SELECT * FROM block WHERE block_no = 10");

//show records by while loop
while($row_list=mysql_fetch_assoc($list)){
?>
<option value="<? echo $row_list['room_no']; ?>"><? echo $row_list['room_no']; ?></option>
<?
// End While loop
}
?>
</select>
<?
}
elseif($select == 'View All')
{
?>
<select name="select" id="select">
<option value="View All">View All </option>
</select>
<?
}
?></td>
<td colspan="4" bordercolor="#666666" class="text">&nbsp;</td>
</tr>
<tr>
<td colspan="6" bordercolor="#666666" class="text"><div align="center">
<p>
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
</div></td>
</tr>
</table>
<div align="center"></div>
</form>
<!-- PopCalendar(tag name and id must match) Tags should not be enclosed in tags other than the html body tag. -->
<iframe width=174 height=189 name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="HelloWorld/ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; top:-500px; left:-500px;">
</iframe>
</div>
</div>
</div>
</body>
</html>

<? include ("include/footer.php"); ?>
[/code]
×

Success!

Help @celest91 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...