2017-04-09 10 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>"; 

また、mysql関数ではなくmysqliを使用して変換する必要があります。後者は廃止され、廃止予定であり、安全性は低くなっています。

関連する問題