我的 mysql 表有 6 个字段 bkid bkname bkauth bkpub bkedn bkstock。这个程序只是为了测试你可能会看到一些我已经注释掉的额外行,因为我现在没有使用注释行。就目前而言,我正在尝试从 html 表单中获取 bkid,然后在查询中使用它来找出 $row 中检索结果的最后一列作为 $row[5],这是库存 bkstock 中的书籍。所以,我需要从用户在表单中提供的bkid中找出库存书籍的数量,然后单击按钮提交表单。
下面给出的查询不起作用。注意:未定义的偏移量:第 41 行 C:\xampp\htdocs\projects\library\incstockbook.php 中的 5
<HTML>
<HEAD>
<h1 align="center">THIS PAGE ADDS STOCK OF BOOKS TO THE LIBRARY</h1>
</HEAD>
TO INCREASE THE STOCK OF BOOKS TO INCLUDE TO THE LIBRARY
<FORM action="incstockbook.php" method="POST">
<table>
<tr>
<td>ENTER THE BOOK ID :</td>
<td><input type=text name="bkid">
</TR>
<TR>
<td>ENTER THE NO. OF BOOKS TO INCLUDE TO THE LIBRARY:</td>
<td><input type=text name="bkstock">
</tr>
</table>
<BR>
CLICK HERE STOCK MORE BOOK :<input type="submit" value="ADD STOCK" name="submit"></br></br>
</FORM>
<?php
$server="localhost";
$username="root";
$password="pramit";
$db="test";
$mysqli = new mysqli($server,$username,$password);
if ($mysqli->errno)
{
printf("Unable to connect to the database:<br /> %s",
$mysqli->error);
exit();
}
$mysqli->select_db($db);
$query1 = "select bkstock from books where bkid=";
if(isset($_POST['submit']))
{
$bkid=$_POST['bkid'];
// $bkstock=$_POST['bkstock'];
$query1.="'$bkid'";
$result=$mysqli->query($query1,MYSQLI_STORE_RESULT);
$row = $result->fetch_array(MYSQLI_NUM);
echo "$row[5]";
}
$mysqli_close;
?>