0
儘管我已經定義了custname,日期和itemnum作爲數組,當運行代碼時我得到錯誤,我曾經使用過上述變量。問題與未定義的索引錯誤
錯誤在最後
CODE
<?php
$con = mysqli_connect("localhost", "root", "","demo");
$custname=array();
$Date=array();
$itemnum=array();
$sql= "SELECT customermst.custid, customermst.custname, purchasemst.purchasedt, purchasemst.itemnum FROM customermst, purchasemst WHERE purchasemst.custid = customermst.custid ORDER BY custid";
echo $sql;
$result=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($result ,MYSQLI_BOTH))
{
$custname[]=$row["customermst.custname"];
$Date[]=$row["purchasemst.purchasedt"];
$itemnum[]=$row["purchasemst.itemnum"];
}
echo '<html><head><title>Reports</title></head><body>
<table>
<tr>
<td>Customer Name</td><td>Date</td><td>Item Number</td>
</tr>';
for($i=0; $i<=count($custname); $i++)
{
echo '<tr><td>'.$custname[$i].'</td><td>'.$Date[$i].'</td> <td>'.$itemnum[$i].'</td></tr>';
}
echo '</table></body></html>';
?>
ERROR
(!) Notice: Undefined index: customermst.custname in C:\wamp64\www\wordpress\project1\mastdtl.php on line 11
Call Stack
# Time Memory Function Location
1 0.0013 238792 {main}() ...\mastdtl.php:0
(!) Notice: Undefined index: purchasemst.purchasedt in C:\wamp64\www\wordpress\project1\mastdtl.php on line 12
Call Stack
# Time Memory Function Location
1 0.0013 238792 {main}() ...\mastdtl.php:0
(!) Notice: Undefined index: purchasemst.itemnum in C:\wamp64\www\wordpress\project1\mastdtl.php on line 13
Call Stack
# Time Memory Function Location
1 0.0013 238792 {main}() ...\mastdtl.php:0
嗨試過你給的解決方案,但仍然是相同的錯誤 – Raj
@Raj現在它可能是解決方案 – Oliver
感謝奧利弗,我在嘗試它之前做了一些錯誤,再次做了它,它的工作。再次感謝。 – Raj