脚本包含将增加 html 中定义的行元素的函数
<SCRIPT language="javascript">
function addRow(tableID) {
var rowNumber = document.getElementById('rowNumber');
rowNumber.value = parseInt( rowNumber.value ) + 1;
}
</script>
表包含将通过单击添加按钮自动生成的行。
我想使用 P_Name[] 和 Make[] 的值从数据库中检索数据以与组合框 Model[] 绑定
获得的错误:- 注意:未定义的变量:在第 117 行的 C:\xampp\htdocs\PhpProject1\transaction1.php 中生成
注意:未定义的变量:C:\xampp\htdocs\PhpProject1\transaction1.php 中的 P_Name 第 117 行
<TABLE id="dataTable" border="1" cellspacing="10">
<input id="rowNumber" type="hidden" name="row" value="1"/>
<TR>
<TD> 1 </TD>
<td><SELECT name="P_Name[]" class="input_text">
<option value="Camera">Camera</option>
<option value="DVR">DVR</option>
<option value="PS">Power supply</option>
<option value="HD">Hard disk</option>
<option value="wire">Wire</option>
</select>
</td>
<td> <select name="Make[]" class="input_text">
<option value="Electronic eye">Electronic eye</option>
<option value="Viewmax">Viewmax</option>
<option value="Hikvision">Hikvision</option>
<option value="Sony">Sony</option>
</select></td>
<TD> <?php
$con = mysqli_connect('localhost','root','','danisco');
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else {
$query = mysqli_query($con, "SELECT p_model FROM product WHERE p_make = '$Make' AND p_name = '$P_Name' " );
echo '<select name="Model[]" class="input_text">';
while ($row = mysqli_fetch_array($query))
{
echo '
<option value="'.$row['p_model'].'">'.$row['p_model'].'</option>
';
}
}
?>
</TD>
<TD> <INPUT name="qty[]"type="text" /> </TD>
<TD> <INPUT name="sno[]"type="text" /> </TD>
</TR>
</TABLE>
<center><INPUT type="button" value="Add Row" onclick="addRow('dataTable');"/> </center>
<label><span><b>Delivery Boy</b></span><input name="d_boy" class="input_text" type="text" size="20" />
<br><input type="submit" id="button1"/>