Retrieve data from MySql database using html form and php
<p>I am new at php and I have read almost all forums, but no result!!! I am trying to retrieve some data from my mySql db using an html form and a php file. The html form called choose.htm is as follows:</p>

<pre><code>    &lt;form name="choose" method = "POST" action = search.php&gt;
    &lt;table&gt;
    &lt;tr&gt;
    &lt;tr&gt;&lt;td height="3"&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;td width="60"&gt;&lt;font1&gt;Denomination&lt;/font1&gt;&lt;/td&gt;
    &lt;td&gt;&lt;Select name = denom&gt;
        &lt;option value="" selected&gt;All&lt;/option&gt;
              &lt;option value="half"&gt;Half Cents&lt;/option&gt;
        &lt;option value="large"&gt;Large Cents&lt;/option&gt;
        &lt;option value="bust"&gt;Bust Dollars&lt;/option&gt;
        &lt;option value="morgan"&gt;Morgan Dollars&lt;/option&gt;
    &lt;/Select&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;
    &lt;tr&gt;&lt;td height="3"&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;td width="60"&gt;&lt;font1&gt;Year&lt;/font1&gt;&lt;/td&gt;
    &lt;td&gt;&lt;Select name = year&gt;
        &lt;option value="" selected&gt;All&lt;/option&gt;
        &lt;option value="1793"&gt;&lt;font4&gt;1793&lt;/font&gt;&lt;/option&gt;      
        &lt;option value="1794"&gt;1794&lt;/option&gt;    
        &lt;option value="1795"&gt;1795&lt;/option&gt;    
        &lt;option value="1796"&gt;1796&lt;/option&gt;    
    &lt;/Select&gt;&lt;/td&gt;&lt;/tr&gt;

    &lt;tr&gt;
    &lt;tr&gt;&lt;td height="3"&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;td width="60"&gt;&lt;font1&gt;Picture&lt;/font1&gt;&lt;/td&gt;
    &lt;td&gt;&lt;Select name = picture&gt;
        &lt;option value="" selected&gt;All&lt;/option&gt;
        &lt;Option value="liberty"&gt;Liberty Cap&lt;/Option&gt;
        &lt;Option value="draped"&gt;Draped Bust&lt;/Option&gt;
        &lt;Option value="classic"&gt;Classic Head&lt;/Option&gt;
        &lt;Option value="chain"&gt;Chain Reverse&lt;/Option&gt;
    &lt;/Select&gt;&lt;/td&gt;&lt;/tr&gt;

   &lt;tr&gt;&lt;td height="3" colspan="2"&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;font1&gt;Text&lt;/b&gt;&lt;/font1&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input name=text type=text&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;/Select&gt;&lt;/td&gt;&lt;/tr&gt;

   &lt;tr&gt;&lt;td&gt;&lt;input name=look type=submit value=Submit&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;/form&gt;
</code></pre>

<p>And the php file called search.php is as follows:</p>

<pre><code>    &lt;html&gt;
    &lt;body&gt;

    &lt;?php
    $username="root";
    $password="";
    $database="xxxxxxxx";

    mysql_connect(localhost,$xxxxxx,$xxxxxx);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM coins";
    $result=mysql_query($query);

    $num=mysql_numrows($result);

    mysql_close();

    echo "&lt;b&gt;&lt;center&gt;US Coins&lt;/center&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;";

    $i=0;
    while ($i &lt; $num) {

    $denom=$_POST["denom"];
    $year=$_POST["year"];
    $picture=$_POST["picture"];
    $text=$_POST["text"];

    echo "$denom&lt;br&gt;Year: $year&lt;br&gt;Picture: $picture&lt;br&gt;Text: $text&lt;br&gt;&lt;br&gt;";

    $i++;
    }
    ?&gt;

    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<p>I am getting an output at the number of rows in my db, with the options that I have selected:</p>

<p>half
Year: 1793
Picture: 
Text: </p>

<p>half
Year: 1793
Picture: 
Text: </p>

<p>........ goes on.</p>

<p>I couldn't solve the problem. All helps will be very much appreciated...</p>

<p>Sarp</p>
