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:
<form name="choose" method = "POST" action = search.php>
<table>
<tr>
<tr><td height="3"></td></tr>
<td width="60"><font1>Denomination</font1></td>
<td><Select name = denom>
<option value="" selected>All</option>
<option value="half">Half Cents</option>
<option value="large">Large Cents</option>
<option value="bust">Bust Dollars</option>
<option value="morgan">Morgan Dollars</option>
</Select></td></tr>
<tr>
<tr><td height="3"></td></tr>
<td width="60"><font1>Year</font1></td>
<td><Select name = year>
<option value="" selected>All</option>
<option value="1793"><font4>1793</font></option>
<option value="1794">1794</option>
<option value="1795">1795</option>
<option value="1796">1796</option>
</Select></td></tr>
<tr>
<tr><td height="3"></td></tr>
<td width="60"><font1>Picture</font1></td>
<td><Select name = picture>
<option value="" selected>All</option>
<Option value="liberty">Liberty Cap</Option>
<Option value="draped">Draped Bust</Option>
<Option value="classic">Classic Head</Option>
<Option value="chain">Chain Reverse</Option>
</Select></td></tr>
<tr><td height="3" colspan="2"></td></tr>
<tr><td><font1>Text</b></font1></td>
<td><input name=text type=text></td></tr>
</Select></td></tr>
<tr><td><input name=look type=submit value=Submit></td></tr>
</form>
And the php file called search.php is as follows:
<html>
<body>
<?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 "<b><center>US Coins</center></b><br><br>";
$i=0;
while ($i < $num) {
$denom=$_POST["denom"];
$year=$_POST["year"];
$picture=$_POST["picture"];
$text=$_POST["text"];
echo "$denom<br>Year: $year<br>Picture: $picture<br>Text: $text<br><br>";
$i++;
}
?>
</body>
</html>
I am getting an output at the number of rows in my db, with the options that I have selected:
half Year: 1793 Picture: Text:
half Year: 1793 Picture: Text:
........ goes on.
I couldn't solve the problem. All helps will be very much appreciated...
Sarp
nameneeds quotes exname="foo"notname = foo