title: PHP editing data from the database
body: <p>i am trying to edit database before updating.first i am trying to edit the database using echo after that i want to update desired fields in the same table.please find my code below....
   please help...i need to fetch values from database patient and need to update in the same table....</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  
      &lt;head&gt;
          &lt;title&gt;Form Edit Data&lt;/title&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;table border=1&gt;
              &lt;tr&gt;
                  &lt;td align=center&gt;MODIFY PATIENT DATA&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;table&gt;
                          &lt;? include "db.php";//database connection $pid=$_POST[ 'pid']; $name=$_POST[
                          'name']; $age=$_POST[ 'age']; $sex=$_POST[ 'sex']; $mobileno=$_POST[
                          'mobileno']; $vaccine=$_POST[ 'vaccine']; $diagno=$_POST[ 'diagno']; $fee=$_POST[
                          'fee']; $order=s printf( "SELECT * FROM `hms`.`patient` WHERE pid='%s'", mysql_real_escape_string($pid));
                          $result=m ysql_query($order); if (!$result) die( 'Error: (' . mysql_errno()
                          . ') ' . mysql_error()); $row=m ysql_fetch_assoc($result); ?&gt;
                          &lt;form method="post" action="update1.php"&gt;
                              &lt;table style=" border:5px solid silver" cellpadding="10px" cellspacing="10px"
                              align="center" border="0"&gt;
                                  &lt;tr&gt;
                                      &lt;td colspan="4" style="background:#0066FF; color:#FFFFFF; fontsize:20px"&gt;PATIENT DETAILS&lt;/td&gt;
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td&gt;Patient Name&lt;/td&gt;
                                      &lt;td&gt;
                                          &lt;input type="text" name="name" size="20" value=&lt;?php echo $row[ 'name'];
                                          ?&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td&gt;Patient ID&lt;/td&gt;
                                      &lt;td&gt;
                                          &lt;input type="text" name="pid" size="20" value=&lt;?php echo $row[ 'pid'];
                                          ?&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td&gt;Age&lt;/td&gt;
                                      &lt;td&gt;
                                          &lt;input type="text" name="age" size="10" value=&lt;?php echo $row[ 'age'];
                                          ?&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td&gt;Sex&lt;/td&gt;
                                      &lt;td&gt;
                                          &lt;input type="text" name="sex" size="20" value=&lt;?php echo $row[ 'sex'];
                                          ?&gt;?&gt;"&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;Mobile No.&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;input type="text" name="mobileno" size="20" value=&lt;?php echo $row[
                                                  'mobileno']; ?&gt;
                                              &lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;Diagnosis&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;input type="text" name="diagno" size="40" value=&lt;?php echo $row[
                                                  'diagno']; ?&gt;
                                              &lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;Vaccine&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;input type="text" name="vaccine" size="20" value=&lt;?php echo $row[
                                                  'vaccine']; ?&gt;
                                              &lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;Fee Received&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;input type="text" name="fee" size="20" value=&lt;?php echo $row[ 'fee'];
                                                  ?&gt;
                                                  &lt;tr&gt;
                                                      &lt;td align="right"&gt;
                                                          &lt;input type="submit" name="submit value" value="UPDATE"&gt;
                                                      &lt;/td&gt;
                                                  &lt;/tr&gt;
                          &lt;/form&gt;
                          &lt;/table&gt;
                          &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/table&gt;
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>My table is showing values like this:</p>
  
  <pre><code>Patient Name &lt;? echo   "&gt;
  Patient ID   &lt;? echo   "&gt;
  .
  .
  .
  .
  Fee Received &lt;? echo    "&gt;
  </code></pre>
  
  <p>It is displaying <code>&lt;? echo   "&gt;</code> I tried to use <code>&lt;?php echo  "&gt;</code> but giving error .... </p>