为什么我的选择表格没有下降?

时间:2017-04-09 16:00:28

标签: javascript php html css mysql

我希望从其他术语中选择表单或组合框中选择客户。 但问题是选择表格没有下降,它会根据表格中的客户数量来复制。你能帮我理解为什么会这样吗?我对此非常不满。我会附上This is what when there is only one customer in the customer table This my problem, the combobox duplicates into two because there are to customers in the customer table

下面的代码和图片



<?php
	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" />
    	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">   
   	<link rel="stylesheet" type="text/css" href="css/dataTables.bootstrap.css">
	<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="js/jquery.dataTables.js"></script>
   	<script type="text/javascript" src="js/dataTables.bootstrap.js"></script>
	

	<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;
      }
      	a1
			{
				color: white;
				font-family: "Tekton Pro", Georgia, Serif;
			}


    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:;">
				<thead style="background-color:white;">
				<th style="text-align:center"><a>CODE</a></th>
				<th style="text-align:left"><a>NAME</a></th>
				<th style="text-align:center"><a>ITEMS LEFT</a></th>
				<th style="text-align:center"><a>PRICE</a></th>
				<th style="text-align:center"><a>CUSTOMER'S NAME</a></th>
				<th style="text-align:center"><a>STOCKS TO BE RELEASED</a></th>
				<th style="text-align:center"><a>AMOUNT TENDERED</a></th>
				<th style="text-align:center"><a>ACTION</a></th>
				</thead>
				<?php

					$res=mysql_query("select * from item order by itemcode asc");
					$itemcode = $_GET['itemcode'];
					while($rowres=mysql_fetch_array($res))
					{		
							echo"<tr style='background-color:#F5F5DC;'>";
							if($itemcode == $rowres['itemcode']){
								echo"<input type='hidden' name='price' value='".$rowres['price']."'></input>";
								echo"<input type='hidden' name='left' value='".$rowres['qty']."'></input>";
							echo"<input type='hidden' name='itemcode' value='".$rowres['itemcode']."'></input>";
							echo"<td style='text-align:center'><a>".$rowres['itemcode']."</a></td>";
							echo"<td style='text-align:left'><a>&nbsp;&nbsp;&nbsp;".$rowres['item_abb']."</a></td>";
							echo"<td style='text-align:center'><a>".$rowres['qty']."</a></td>";
							echo"<td style='text-align:left'><a class='icon-usd'></a>";
							echo"<a>".number_format($rowres['price']).".00</a></td>";
							$result2=mysql_query("select*from customer ");
							while($row=mysql_fetch_array($result2))
							echo"<td><select name='cusname' class='field'><option value='".$row['cuscode']."'>".$row['name']."</option></select></td>";
							echo"<td style='text-align:center;'><input type='text' style='font-family:tekton pro; text-align:center;' class='field' name='qty' value=''></input></td>";
							echo"<td style='text-align:center;'><input type='text' style='font-family:tekton pro; text-align:center;' class='field' name='amount' value=''></input></td>";
							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>";
						}
						else{
							echo"<td style='text-align:center'><a>".$rowres['itemcode']."</a></td>";
							echo"<td style='text-align:left'><a>&nbsp;&nbsp;&nbsp;".$rowres['item_abb']."</a></td>";
							echo"<td style='text-align:center'><a>".$rowres['qty']."</a></td>";
							echo"<td style='text-align:left'><a class='icon-usd'></a>";
							echo"<a>".number_format($rowres['price']).".00</a></td>";
							echo"<td style='text-align:center'><a></a></td>";
							echo"<td style='text-align:center'><a></a></td>";
							echo"<td style='text-align:center'><a></a></td>";
							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>";	
			}	
							echo"</tr>";
						}	
						
				?>
	</table>
	<script type="text/javascript">
		  $(document).ready(function () {
		  $('#tblContact').dataTable({
			  "iDisplayLength": 10,
				  "lengthMenu": [5,10, 25, 50]
		});
 	});
	</script>
		</form>
</center>
</body>
<html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

因为您在循环中包含 select 标记,所以它会重复,因此您会获得多个下拉列表。只有选项选项卡应位于循环内。

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函数。后者已经过时并被弃用,而且安全性较低。