title: replace div with php content
body: <p>i have a div . when i click on any sub-element list-item, i am posting the item no. to a php file which displays a some details corresponding to that list item. but there are two problems :</p>
  
  <p>first, i want to replace the div  with the content of the php file..
  second, i am getting an error while processing the php file :</p>
  
  <pre><code>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
  </code></pre>
  
  <p>the div looks like:</p>
  
  <pre><code>&lt;div id="list"&gt;
              &lt;?php
  
              $query = "SELECT * from workflow WHERE name = '$username' ORDER BY msg_id DESC";
              $result = mysql_query($query) or die("ERROR: $query.".mysql_error());
  
                  while ($row = mysql_fetch_object($result)) {
                      echo "&lt;div class=list-item-wrap&gt;";
                      echo "&lt;a href='#'&gt;&lt;input class=msgid type=hidden value=".$row-&gt;msg_id."&gt;&lt;div class=list-item&gt;";
                      echo "&lt;b&gt;&lt;h1&gt;".$row-&gt;subject."&lt;/h1&gt;&lt;/b&gt;".substr($row-&gt;message, 0, 200)."...&lt;br&gt;&lt;b&gt;".$row-&gt;sender."&lt;/b&gt;";
                      echo "&lt;/div&gt;&lt;/a&gt;&lt;/div&gt;";
                  }
              ?&gt;
                  &lt;br&gt;
              &lt;/div&gt;
  
  
      &lt;/div&gt;
  </code></pre>
  
  <p>the php file looks like: </p>
  
  <pre><code>&lt;?php
  include 'header.php';
  
  $msg_id = $_POST['msg_id'];
  //$msg_id = 1;
  
  $query = "SELECT * from workflow WHERE msg_id = $msg_id";
  $result = mysql_query($query) or die (mysql_error());
          //echo $row-&gt;username;
  
  if (mysql_num_rows($result) &gt; 0){
      while ($row = mysql_fetch_object($result)) {
          echo "&lt;div id=display-wrap&gt;";
          echo "&lt;h1&gt;".$row-&gt;sender."&lt;/h1&gt;&lt;br&gt;";
          echo "&lt;h2&gt;".$row-&gt;subject."&lt;/h2&gt;";
          echo "&lt;h3&gt;".$row-&gt;datetime."&lt;/h3&gt;&lt;br&gt;";
          echo "&lt;h3&gt;".$row-&gt;message."&lt;/h3&gt;&lt;br&gt;";
          echo "&lt;/div&gt;";
      }
  }
  
  ?&gt;
  </code></pre>