title: Printing a selected value in the drop down list using php?
body: <p>I have trying to print the selected value in the drop down list, but in vain. I am new to php and html, so this might sound like a stupid question but please help me out! this is my code:</p>
  
  <pre><code>echo '&lt;tr&gt;&lt;td&gt;Client:&lt;/td&gt;&lt;td&gt;&lt;select name="client_name"&gt;';   
              $sql = mysql_query("SELECT * FROM client");
              $s= mysql_query("SELECT project.client_id, client_name, client.client_id FROM client,project where project.client_id=client.client_id AND project_id='$editId'");
            //  $s2= mysql_fetch_array($s);
              while ($row = mysql_fetch_array($sql))
              {
                 while ($s2==mysql_fetch_array($s))
                 { 
                  if ($row['client_id'] == $s2['client_id'])
                   $selected = "selected=\"selected\"";
                     else
                          $selected = " ";                                                                         
                 }     
                 echo '&lt;option value="' . $row['client_id'] . '" ' . ($selected == $row['client_id'] ? ' selected' : '') . '&gt;' . $s2['client_name'] . '&lt;/option&gt;';
              }
  </code></pre>
  
  <p>This code doesnt work. Please help me out! Is there a different way to do it?</p>