title: add new option into select with values from php
body: <p>I want to add a dynamic select list, which contain my data from php. how should i do it? i also wanted to have arguments with variables from other php file e.g $mentor==$rows. appreciate it</p>
  
  <pre><code>&lt;th&gt;&lt;select name="mentor" style="width:95%"&gt;
          &lt;?php
              $dbhost = 'localhost';
              $dbuser = 'root';
              $dbpass = '';
              $conn = mysql_connect($dbhost, $dbuser, $dbpass);
              mysql_select_db("testproject", $conn);
  
              if(! $conn )
              {
                  die('Could not connect: ' . mysql_error());
              }
  
              $sql = "SELECT mtrname FROM mentors";
              $sql2 = "SHOW COLUMNS from mentors";
              $result= mysql_query( $sql, $conn );
              if(! $result)
              {
                  die('Could not get data: ' . mysql_error());
              }
              $fetchrow = mysql_fetch_row($sql2);
              $num = count($fetchrow);
              while($rows = mysql_fetch_array($result))
              {
                  for($i=0;$i&lt;$num;$i++)
                  {
                       $rows[$i];
                  }
              }   
              mysql_close($conn);
          ?&gt;
          &lt;option value="&lt;?php echo $mentor?&gt;" &lt;?php if($mentor==$rows[i]) echo 'selected'?&gt;&gt;&lt;?php echo $mentor?&gt;&lt;/option&gt;
          &lt;/select&gt;&lt;/th&gt;
  </code></pre>
  
  <p>edited:
  so i am trying to put select option into when the user first include the data. what i've tried is
  <code>&lt;?php
                  $dbhost = 'localhost';
                  $dbuser = 'root';
                  $dbpass = '';
                  $conn = mysql_connect($dbhost, $dbuser, $dbpass);
                  mysql_select_db("testproject", $conn);
                  if(! $conn )
                  {
                      die('Could not connect: ' . mysql_error());
                  }
                  $sql = "SELECT mtrname FROM mentors";
                  $sql2 = "SHOW COLUMNS from mentors";
                  $result= mysql_query( $sql, $conn );
                  if(! $result)
                  {
                      die('Could not get data: ' . mysql_error());
                  }
                  $fetchrow = mysql_fetch_row($sql2);
                  $num = count($fetchrow);
                  while($rows = mysql_fetch_array($result))
                  {
                  for($i=0;$i&lt;$num;$i++)
                      {
                       echo"&lt;option value='".$rows[i]."&gt;".$rows[i]."&lt;/option&gt;";
                      }
                  }<br>
                  mysql_close($conn);
              ?&gt;</code></p>
  
  <p>but it doesnt display anything from the mentor table. is my code incorrect or its my mysql database issue?</p>