各製品の編集と削除の 2 つのリンクと共に、製品のリストを表示するフォームを作成しました。
php コードの list_recorder.php ページを参照してください...
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="xxx"; // Mysql password
$db_name="shopone"; // Database name
$tbl_name="product"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("shopone")or die("cannot select DB");
$sql="SELECT * FROM product";
$result=mysql_query($sql);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="4"><strong>List data from mysql </strong> </td>
</tr>
<tr>
<td align="center"><strong>product name</strong></td>
<td align="center"><strong>category</strong></td>
<td align="center"><strong>retial price</strong></td>
<td align="center"><strong>price</strong></td>
<td align="center"><strong>detail</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><?php echo $rows['product_name']; ?></td>
<td><?php echo $rows['product_category']; ?></td>
<td><?php echo $rows['product_retail_price']; ?></td>
<td><?php echo $rows['product_price']; ?></td>
<td><?php echo $rows['product_detail']; ?></td>
<td align="center"><a href="update.php?product_id=<? echo $rows['product_id']; ?>">update</a></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
<?php
mysql_close();
?>
このリストはうまく機能しています。次のステップは、製品情報を変更できるように編集することです..
update.phpページと呼ばれる編集コードページを参照してください
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="xxx"; // Mysql password
$db_name="shopone"; // Database name
$tbl_name="product"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("shopone")or die("cannot select DB");
$sql="SELECT * FROM product";
$result=mysql_query($sql);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="4"><strong>List data from mysql </strong> </td>
</tr>
<tr>
<td align="center"><strong>product name</strong></td>
<td align="center"><strong>category</strong></td>
<td align="center"><strong>retial price</strong></td>
<td align="center"><strong>price</strong></td>
<td align="center"><strong>detail</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><?php echo $rows['product_name']; ?></td>
<td><?php echo $rows['product_category']; ?></td>
<td><?php echo $rows['product_retail_price']; ?></td>
<td><?php echo $rows['product_price']; ?></td>
<td><?php echo $rows['product_detail']; ?></td>
<td align="center"><a href="update.php?product_id=<? echo $rows['product_id']; ?>">update</a></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
<?php
mysql_close();
?>
list_recorder.php ページを実行し、リストから編集リンクの 1 つを押すと、エラーが表示されます。
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\VertrigoServ\www\shopone\admin\cd\update.php on line 19
$rows=mysql_fetch_array($result); に関連するものです。このエラーの意味がわかりません。どうすれば解決できますか。
助けてくださいありがとう。
午前