<html>
<head><meta http-equiv=Content-Type content="text/html; charset=utf-8"></head>
<body>
<?php
$connection = mysql_connect("localhost","root","password");
mysql_select_db("test",$connection);
mysql_query("SET NAMES UTF8");
$query = ("SELECT customer.CustName,customer.CustNo,customer.Tel, supply.Qty,stock.ProductName,stock.PricePerUni
FROM customer INNER JOIN supply ON customer.CustNo = supply.CustNo;
INNER JOIN stock ON stock.CustNo = supply.CustNo;
ON customer.CustNo=supply.CustNo,stock.ProductCode=supply.ProductCode
ORDER BY customers.CustNo;");
$result = mysql_query($query);
?>
<table align="center" border="1">
<tr>
<th>CustNo <th>CustName <th>Sex <th>Address <th>Tel <th>ProductCode <th>Qty <th>ProductName <th>PricePerUni <th>StockQty
</tr>
<?
//$connection = mysql_connect("localhost","root","password");
while($data = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>".$data['CustNo'];
echo "<td>".$data['CustName'];
echo "<td>".$data['Sex'];
echo "<td>".$data['Address'];
echo "<td>".$data['Tel'];
echo "<td>".$data['ProductCode'];
echo "<td>".$data['Qty'];
echo "<td>".$data['ProductName'];
echo "<td>".$data['PricePerUni'];
echo "<td>".$data['StockQty'];
echo "</tr>";
}
"</table>";
mysql_close($connection);
?>
</body>
</html>
คือ mysql_fetch_array (): supplied argument is not a valid MySQL result resource in C:\AppServ\www\webpro.php on line 21
ลองเปลี่ยนไปใช้ mysql_fetch_assoc() ก็ยังใช้ไม่ได้อ่ะค่ะ รบกวนพี่ๆช่วยตอบหน่อยนะคะ ขอบคุณมากค่ะ พอดีพึ่งลองฝึกทำครั้งแรกน่ะค่ะ
PHP&MySQL(mysql_fetch_array()ใช้ไม่ได้)
<head><meta http-equiv=Content-Type content="text/html; charset=utf-8"></head>
<body>
<?php
$connection = mysql_connect("localhost","root","password");
mysql_select_db("test",$connection);
mysql_query("SET NAMES UTF8");
$query = ("SELECT customer.CustName,customer.CustNo,customer.Tel, supply.Qty,stock.ProductName,stock.PricePerUni
FROM customer INNER JOIN supply ON customer.CustNo = supply.CustNo;
INNER JOIN stock ON stock.CustNo = supply.CustNo;
ON customer.CustNo=supply.CustNo,stock.ProductCode=supply.ProductCode
ORDER BY customers.CustNo;");
$result = mysql_query($query);
?>
<table align="center" border="1">
<tr>
<th>CustNo <th>CustName <th>Sex <th>Address <th>Tel <th>ProductCode <th>Qty <th>ProductName <th>PricePerUni <th>StockQty
</tr>
<?
//$connection = mysql_connect("localhost","root","password");
while($data = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>".$data['CustNo'];
echo "<td>".$data['CustName'];
echo "<td>".$data['Sex'];
echo "<td>".$data['Address'];
echo "<td>".$data['Tel'];
echo "<td>".$data['ProductCode'];
echo "<td>".$data['Qty'];
echo "<td>".$data['ProductName'];
echo "<td>".$data['PricePerUni'];
echo "<td>".$data['StockQty'];
echo "</tr>";
}
"</table>";
mysql_close($connection);
?>
</body>
</html>
คือ mysql_fetch_array (): supplied argument is not a valid MySQL result resource in C:\AppServ\www\webpro.php on line 21
ลองเปลี่ยนไปใช้ mysql_fetch_assoc() ก็ยังใช้ไม่ได้อ่ะค่ะ รบกวนพี่ๆช่วยตอบหน่อยนะคะ ขอบคุณมากค่ะ พอดีพึ่งลองฝึกทำครั้งแรกน่ะค่ะ