2017-04-09 58 views
1

我想從選擇窗體或其他術語中的組合框中選擇客戶。 但問題是選擇表格不下降,它根據表中有多少客戶在哪裏進行復制。你能幫我理解爲什麼會發生這種情況嗎?我對此感到非常困擾。我會在下方附上This is what when there is only one customer in the customer tableThis my problem, the combobox duplicates into two because there are to customers in the customer table爲什麼我的選擇表單不下降?

<?php 
 
\t include('dbconnect.php'); 
 
    include('home.php'); 
 
?> 
 
<?php include('session.php'); ?> 
 
<html> 
 
<head> 
 
    <link rel="stylesheet" href="assets/demo.css"> 
 
    <link rel="stylesheet" href="assets/form-login.css"> 
 
    <link href="assets/css/font-awesome.css" rel="stylesheet" /> 
 
    \t <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"> 
 
    \t <link rel="stylesheet" type="text/css" href="css/dataTables.bootstrap.css"> 
 
\t <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script> 
 
    <script type="text/javascript" src="js/jquery.dataTables.js"></script> 
 
    \t <script type="text/javascript" src="js/dataTables.bootstrap.js"></script> 
 
\t 
 

 
\t <title>Stock Out</title> 
 
<style> 
 
    
 
    body 
 
{ 
 
    background:url('img/bg.png'); 
 
     background-repeat:repeat; 
 
} 
 

 

 

 
    p 
 
     { 
 
     color: black; 
 
     font-family: "TekTon Pro", Georgia, Serif; 
 
     } 
 
     a 
 
     { 
 
     color: black; 
 
     font-family: "TekTon Pro", Georgia, Serif; 
 
     } 
 
     \t a1 
 
\t \t \t { 
 
\t \t \t \t color: white; 
 
\t \t \t \t font-family: "Tekton Pro", Georgia, Serif; 
 
\t \t \t } 
 

 

 
    a:hover{text-decoration:none} 
 
    </style> 
 
</head> 
 
<body> 
 
<body> 
 
<center> 
 

 
<div style="margin-left:0px; margin-right:0px;"> 
 
<form action="saveoutstock.php" method="post"> 
 
<table class="table table-bordered" id="tblContact" style="width:100%; background-color:;"> 
 
\t \t \t \t <thead style="background-color:white;"> 
 
\t \t \t \t <th style="text-align:center"><a>CODE</a></th> 
 
\t \t \t \t <th style="text-align:left"><a>NAME</a></th> 
 
\t \t \t \t <th style="text-align:center"><a>ITEMS LEFT</a></th> 
 
\t \t \t \t <th style="text-align:center"><a>PRICE</a></th> 
 
\t \t \t \t <th style="text-align:center"><a>CUSTOMER'S NAME</a></th> 
 
\t \t \t \t <th style="text-align:center"><a>STOCKS TO BE RELEASED</a></th> 
 
\t \t \t \t <th style="text-align:center"><a>AMOUNT TENDERED</a></th> 
 
\t \t \t \t <th style="text-align:center"><a>ACTION</a></th> 
 
\t \t \t \t </thead> 
 
\t \t \t \t <?php 
 

 
\t \t \t \t \t $res=mysql_query("select * from item order by itemcode asc"); 
 
\t \t \t \t \t $itemcode = $_GET['itemcode']; 
 
\t \t \t \t \t while($rowres=mysql_fetch_array($res)) 
 
\t \t \t \t \t { \t \t 
 
\t \t \t \t \t \t \t echo"<tr style='background-color:#F5F5DC;'>"; 
 
\t \t \t \t \t \t \t if($itemcode == $rowres['itemcode']){ 
 
\t \t \t \t \t \t \t \t echo"<input type='hidden' name='price' value='".$rowres['price']."'></input>"; 
 
\t \t \t \t \t \t \t \t echo"<input type='hidden' name='left' value='".$rowres['qty']."'></input>"; 
 
\t \t \t \t \t \t \t echo"<input type='hidden' name='itemcode' value='".$rowres['itemcode']."'></input>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:center'><a>".$rowres['itemcode']."</a></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:left'><a>&nbsp;&nbsp;&nbsp;".$rowres['item_abb']."</a></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:center'><a>".$rowres['qty']."</a></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:left'><a class='icon-usd'></a>"; 
 
\t \t \t \t \t \t \t echo"<a>".number_format($rowres['price']).".00</a></td>"; 
 
\t \t \t \t \t \t \t $result2=mysql_query("select*from customer "); 
 
\t \t \t \t \t \t \t while($row=mysql_fetch_array($result2)) 
 
\t \t \t \t \t \t \t echo"<td><select name='cusname' class='field'><option value='".$row['cuscode']."'>".$row['name']."</option></select></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:center;'><input type='text' style='font-family:tekton pro; text-align:center;' class='field' name='qty' value=''></input></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:center;'><input type='text' style='font-family:tekton pro; text-align:center;' class='field' name='amount' value=''></input></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:center;'><button style='padding:4px 10px; font-family:tekton pro;' class='btn btn-success'><span class='icon-save'></span>&nbsp;&nbsp;Save&nbsp;&nbsp;</button></td>"; 
 
\t \t \t \t \t \t } 
 
\t \t \t \t \t \t else{ 
 
\t \t \t \t \t \t \t echo"<td style='text-align:center'><a>".$rowres['itemcode']."</a></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:left'><a>&nbsp;&nbsp;&nbsp;".$rowres['item_abb']."</a></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:center'><a>".$rowres['qty']."</a></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:left'><a class='icon-usd'></a>"; 
 
\t \t \t \t \t \t \t echo"<a>".number_format($rowres['price']).".00</a></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:center'><a></a></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:center'><a></a></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:center'><a></a></td>"; 
 
\t \t \t \t \t \t \t echo"<td style='text-align:center;'><a style='padding:4px 10px;' href='outstock.php?itemcode=$rowres[itemcode]' class='btn btn-primary'><span class='icon-signin'></span>&nbsp;Stock Out</button></td>"; \t 
 
\t \t \t } \t 
 
\t \t \t \t \t \t \t echo"</tr>"; 
 
\t \t \t \t \t \t } \t 
 
\t \t \t \t \t \t 
 
\t \t \t \t ?> 
 
\t </table> 
 
\t <script type="text/javascript"> 
 
\t \t $(document).ready(function() { 
 
\t \t $('#tblContact').dataTable({ 
 
\t \t \t "iDisplayLength": 10, 
 
\t \t \t \t "lengthMenu": [5,10, 25, 50] 
 
\t \t }); 
 
    \t }); 
 
\t </script> 
 
\t \t </form> 
 
</center> 
 
</body> 
 
<html>

+0

您在循環中包含選擇選項卡。它應該在循環之前,循環之後的閉合選擇標籤。只有選項應該在循環中。 –

+0

謝謝@SloanThrasher。 。我的問題解決了。感謝您的快速響應 –

+0

如果它能工作,請接受答案。 –

回答

2

代碼和圖片因爲你包括選擇循環內標籤,它重複等你拿多個下拉菜單。只有選項選項卡應該在循環中。

echo "<a>".number_format($rowres['price']).".00</a></td>"; 
$result2 = mysql_query("select * from `customer`;"); 
echo "<td><select name='cusname' class='field'>"; 
while($row = mysql_fetch_array($result2)) { 
    echo "<option value='".$row['cuscode']."'>".$row['name']."</option>"; 
} 
echo "</select></td>"; 

此外,你應該轉換爲使用mysqli而不是mysql函數。後者已經過時並且被棄用,並且它們不太安全。

相關問題