title: How to populate php/html form with MySQL data
body: <p>I am trying to create a program in which a user can update any specific product. When a user click on <code>UPDATE</code> button, a form opens. I want to populate <code>HTML</code> form with <code>MySQL</code> data. I have written the following code but its giving me an error message. I am sharing just the <code>HTML</code> part of the code.I am using this FORM inside PHP echo. Kindly check it.  </p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;label&gt;Product Name:&lt;/label&gt;  
  &lt;/td&gt;
  &lt;td&gt;
      &lt;input type='text' name='product_name' value='&lt;?php echo $fetch['product_id']; ?'/&gt;*Required  
  &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p><strong>Error message:</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><em><strong>COMPLETE CODE</em></strong></p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;?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 "  
                  &lt;form action='insert_product.php' method='POST' enctype='multipart/form-data' &gt;
                  &lt;table border=1&gt;
                  &lt;tr&gt;
                  &lt;td&gt;
  
                  &lt;label&gt;Product Name:&lt;/label&gt; &lt;/td&gt;  &lt;td&gt;&lt;input type='text' 
                  name='product_name' value='&lt;?php echo $fetch['product_id']; ?&gt;'  /&gt;*Required&lt;/td&gt;&lt;/tr&gt;
  
                  &lt;tr&gt;&lt;td&gt;&lt;label&gt;Item No:&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' name='item_no' &gt;&lt;/td&gt;&lt;/tr&gt;
  
  
              &lt;tr&gt;&lt;td&gt;    Image3:&lt;/td&gt;&lt;td&gt; &lt;input type='file' name= 'image3' &gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;  ";
  
  
  /*------------------
  Drop Down List Start
  ------------------  */      
  
  
              echo "&lt;select name='category'&gt;";
  
                  $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 "&lt;option value='".$select_query_array['category_id']."' &gt;".
                          htmlspecialchars($select_query_array["name"]).
  
                          "&lt;option value='".$sub_query_run['sub_category_id']."'  &gt;" .
                          htmlspecialchars($sub_query_run['sub_category_name']).   "&lt;/option&gt;".
  
                  "&lt;/option&gt;";
  
  
  
  
              }
              echo "&lt;/br&gt;";
  
           $selectTag= "&lt;/br&gt;&lt;input type='submit' value='Update Product'  /&gt;&lt;/select&gt;&lt;/form&gt;";
  
           echo "&lt;/div&gt;&lt;/div&gt;";
  
           echo $selectTag;
  </code></pre>
  
  <p>Thanks</p>