I created forms to show list of product along with two links of edit and delete for each product.
please see list_recorder.php page of php code...
<?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();
?>
This list are works great and now my next step is to work on edit to allow me to change product information..
please see edit code page which is called update.php page
<?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();
?>
And when I run list_recorder.php page and I pressed one of edit link from the list, I'm getting errors it said
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\VertrigoServ\www\shopone\admin\cd\update.php on line 19
Which is for relate to $rows=mysql_fetch_array($result); i'm not sure what this error mean and how can i solve that!
please help thanks.
AM