//////////////////////////นับคนว่าง////////////////////////////////////
$selemp2 = "select emid,emstatus,sum(emmodel+emlighting_materiel+emend) AS SUM ";
$selemp2 .= "from tblemployee group by emid having emstatus = 1 ";
$selemp2 .= "and emid not in (select emid from tblrespon) order by SUM DESC";
$selemp2_query = mysql_query($selemp2);
$count_emp_noWork = mysql_num_rows($selemp2_query);
//echo $count_emp_noWork;
////////////////////////////////////////////////////////////////////
//Begin While Show Quotetion
$i=1;
$select_quote_detail = "select * from tblquotation_detail where quid = '$ID'";
$query_quote_detail = mysql_query($select_quote_detail);
while($quote_detail = mysql_fetch_array($query_quote_detail))
{
<select name="selemp1[]" id="selemp1">
<?php
//////แสดง พนักงานใน listbox\\\\\\\\\\
$showemp = "select emid,emname_thai from tblemployee";
$showemp_query = mysql_query($showemp);
////////////////////////////////////////////////////////////////////
while($emplist = mysql_fetch_array($showemp_query))
{ $n = $i-1;
///////////////////////////เลือกพนักงาน///////////////////////////////////
if($count_emp_noWork != 0)
{
$selemp_listbox = "select emid,emname_thai,emstatus,sum(emmodel+emlighting_materiel+emend) AS SUM ";
$selemp_listbox .= "from tblemployee group by emid having emstatus = 1 ";
$selemp_listbox .= "and emid not in (select emid from tblrespon) order by SUM DESC,emid limit $n,1";
}
else
{
$selemp_listbox = "select emid,emname_thai,emstatus,sum(emmodel+emlighting_materiel+emend) AS SUM ";
$selemp_listbox .= "from tblemployee group by emid having emstatus = 1 order by SUM DESC,emid limit $n,1";
}
$query = mysql_query($selemp_listbox);
$empsel = mysql_fetch_array($query);
$selectemp = $empsel['emid'];
<option value="<?php echo $emplist['emid']; ?>" <?php if( $emplist['emid'] == $selectemp ) {echo "selected=\"selected\"";}></option>
}