<?
$link = mysql_connect('localhost', 'root', ''); //changet the configuration in required
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('leonexdb');
$query1="select a.e_emp_name from mst_employee_detail a,mst_experience_detail b where a.e_emp_code=b.e_exp_empcode AND b.e_exp_desigination = 'Tele Marketing Executive' AND a.e_del_flag = 'N'";
$result1=mysql_query($query1);
?>
<form action="third.php" method="post" name="checkform">
TeleCaller
<select name="empname1">
<option>Select TeleCaller</option>
<? while($row=mysql_fetch_array($result1)) { ?>
<option value><?=$row['e_emp_name']?> </option>
<? } ?>
</select><br>
<input type="submit" />
</form>
and my third.php code is
<?php
$link = mysql_connect("localhost", "root", "")
or die("Could not connect");
$db = mysql_select_db("leonexdb", $link)
or die("Could not select database");
$Get_cust_details= mysql_query("Select * From los_master_detail where los_tele_caller = '.$_POST[empname1].'",$link); //check for chrages exists in the charges table
$df=mysql_num_rows($Get_cust_details);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#333300" link="#FFFF00" vlink="#CCCC33" alink="#FFFF99">
<p> </p>
<table width="100%" border="1" align="center" cellspacing="1" bordercolor="#0000FF">
<tr>
<td width="8%">SerialNo</td>
<td width="8%">Loan Type</td>
<td width="15%">Login No</td>
<td width="23%">Login Date </td>
<td width="31%">Pending Date</td>
<td width="31%">Customer Name</td>
<td width="31%">Company Name</td>
<td width="31%">Tele Caller</td>
<td width="31%">Team Leader</td>
<td width="31%">Loan Amount</td>
<td width="31%">Approved Amt</td>
<td width="31%">Approved Date</td>
<td width="31%">PDC Date</td>
<td width="31%">End Date</td>
<td width="31%">End Amount</td>
<td width="31%">Status</td>
<td width="31%">Tenure</td>
</tr><?php for($i=0;$i<=$df;$i++) { while ( $thearray = mysql_fetch_array($Get_cust_details ))
{ $Serial=$thearray[0];
$Ltype=$thearray[1];
$Lno=$thearray[2];
$Ldate=$thearray[3];
$Pdate=$thearray[4];
$Name=$thearray[6];
$CName=$thearray[7];
$caller=$thearray[15];
$leader=$thearray[16];
$amt=$thearray[18];
$appamt=$thearray[20];
$appdate=$thearray[19];
$pdcdate=$thearray[24];
$enddate=$thearray[21];
$endamt=$thearray[22];
$status=$thearray[26];
$tenure=$thearray[28];
?>
<tr>
<td><?php echo $Serial;?></td>
<td><?php echo $Ltype;?></td>
<td><?php echo $Lno;?></td>
<td><?php echo $Ldate;?></td>
<td><?php echo $Pdate;?></td>
<td><?php echo $Name;?></td>
<td><?php echo $CName;?></td>
<td><?php echo $caller;?></td>
<td><?php echo $leader;?></td>
<td><?php echo $amt;?></td>
<td><?php echo $appamt;?></td>
<td><?php echo $appdate;?></td>
<td><?php echo $pdcdate;?></td>
<td><?php echo $enddate;?></td>
<td><?php echo $endamt;?></td>
<td><?php echo $status;?></td>
<td><?php echo $tenure;?></td>
<?php } }?>
</tr>
</table>
<p align="right"> </p>
<p> </p>
</body>
</html>
in the above code the option values or not retrieve. kindly help me...
how to fetch dropdown data from database
Moderator: General Moderators
-
saran_tvmalai
- Forum Newbie
- Posts: 5
- Joined: Fri Sep 19, 2008 7:42 am
Re: how to fetch dropdown data from database
User below given code for dropdown and replace the database field name(database_field_name) for option value array .
<select name="empname1">
<option>Select TeleCaller</option>
<? while($row=mysql_fetch_array($result1)) { ?>
<option value="<?=$row['database_field_name']?>"><?=$row['e_emp_name']?> </option>
<? } ?>
</select>
<select name="empname1">
<option>Select TeleCaller</option>
<? while($row=mysql_fetch_array($result1)) { ?>
<option value="<?=$row['database_field_name']?>"><?=$row['e_emp_name']?> </option>
<? } ?>
</select>
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: how to fetch dropdown data from database
Your option tag syntax is incorrect.
Code: Select all
<option value="something">something</option>- Weasel5-12
- Forum Commoner
- Posts: 37
- Joined: Tue Sep 16, 2008 6:58 am
Re: how to fetch dropdown data from database
Code: Select all
echo "<select name='empname1[]'><br>\n";
while ($row1 = mysql_fetch_array($result_1)){
extract($row1);
echo "<option value='".$e_emp_name."'>".$e_emp_name."<br>\n";
}
echo "</select>";use this for gathering ur selected items
Code: Select all
<?php
$var1 = $_POST['empname1'];
for($i=0; $i<sizeof($var1);$i++){
echo $var1[$i]."<br>";
}
?>dunno if this is what u need but, this works very well for me.
-
saran_tvmalai
- Forum Newbie
- Posts: 5
- Joined: Fri Sep 19, 2008 7:42 am
Re: how to fetch dropdown data from database
thanks alot its working