I am trying to create a program in which a user can update any specific product. When a user click on UPDATE
button, a form opens. I want to populate HTML
form with MySQL
data. I have written the following code but its giving me an error message. I am sharing just the HTML
part of the code.I am using this FORM inside PHP echo. Kindly check it.
HTML:
<label>Product Name:</label>
</td>
<td>
<input type='text' name='product_name' value='<?php echo $fetch['product_id']; ?'/>*Required
</td>
</tr>
Error message:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE),
expecting identifier (T_STRING) or variable (T_VARIABLE) or number
(T_NUM_STRING) in F:\xampp\htdocs\CMS\update_single_product.php
COMPLETE CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
<?php
include 'connect.php';
$id= $_GET['product_id'];
$select_query= "select * from products Left join product_description
ON products.product_id=$id and product_description.product_id=$id";
if(!$select_query_run= mysql_query($select_query))
{
echo mysql_error();
}
else
{
$fetch = mysql_fetch_array ($select_query_run);
echo "
<form action='insert_product.php' method='POST' enctype='multipart/form-data' >
<table border=1>
<tr>
<td>
<label>Product Name:</label> </td> <td><input type='text'
name='product_name' value='<?php echo $fetch['product_id']; ?>' />*Required</td></tr>
<tr><td><label>Item No:</label></td> <td><input type='text' name='item_no' ></td></tr>
<tr><td> Image3:</td><td> <input type='file' name= 'image3' ></td></tr></table> ";
/*------------------
Drop Down List Start
------------------ */
echo "<select name='category'>";
$select_query= 'Select * from category';
$select_query_run = mysql_query($select_query);
$sub_category_query= "Select * from sub_categories";
$sub_query_run= mysql_query($sub_category_query);
while ($select_query_array= mysql_fetch_array($select_query_run) )
{
echo "<option value='".$select_query_array['category_id']."' >".
htmlspecialchars($select_query_array["name"]).
"<option value='".$sub_query_run['sub_category_id']."' >" .
htmlspecialchars($sub_query_run['sub_category_name']). "</option>".
"</option>";
}
echo "</br>";
$selectTag= "</br><input type='submit' value='Update Product' /></select></form>";
echo "</div></div>";
echo $selectTag;
Thanks