Code: Select all
<?php
session_start();
$d= $_SESSION['txt_id'];
include ('dbinfo.inc');
echo mysql_error();
?>
<body bgcolor="#cfad5f"text="#1f180a">
<form action="req_logic.php" method="post">
</br></br></br>
<p height="10">
<font face="times new roman" size="5"><b><big></font><center>
<font color="#532900" size="5" face="times new roman">Request Form</font>
</center>
</P>
<table align = "center" style="text-align:Left" width = "600" frame = "box" bordercolor="black" >
<tr>
<td width="252" font size="3"><font color="#532900" size="5">Department:</font></td>
<td width="336"><div align="center">
<p>
<label>
<?php
$query="SELECT emp_department FROM login";
/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */
$result = mysql_query ($query);
echo "<select name='menu_dept'>";
// printing the list box select command
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[emp_department]>$nt[emp_department]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
?>
Code: Select all
$dept=mysql_real_escape_string($_POST['menu_dept']);
$dept=mysql_real_escape_string($_POST['menu_dept'][$row]);
mysql_query("INSERT INTO request(,req_for_dept,) Values ('$dept')");