Hi...
I have connected to a MySQL database that contains information on various companies. I have created a HTML form with 4 drop down list boxes that have static information to (hopefully) search the database including company size, location, sector, etc. The user will select items from the drop down list boxes and click go to retrieve the required data.
For example, a user may want to search for all medium sized companies in Leicester in the IT sector. The PHP code I have so far is as follows;
mysql_select_db(\"beacon\",$db);
if($_POST[\'company_size\'] == 1)
$where = \'company_size BETWEEN 1 AND 9\';
if($_POST[\'company_size\'] == 2)
$where = \'company_size BETWEEN 10 AND 49\';
if($_POST[\'company_size\'] == 3)
$where = \'company_size BETWEEN 50 AND 250\';
if($_POST[\'County\'] == 1)
$where1 = \'County LIKE Derbyshire\';
if($_POST[\'County\'] == 2)
$where1 = \'County LIKE Leicestershire\';
if($_POST[\'County\'] == 3)
$where1 = \'County LIKE Lincolnshire\';
if($_POST[\'County\'] == 4)
$where1 = \'County LIKE Northants\';
if($_POST[\'County\'] == 5)
$where1 = \'County LIKE Nottinghamshire\';
$result = mysql_query(\"SELECT name, County, sector, company_size \" .
\"FROM beacon \" .
\"WHERE\". $where .\"AND\". $where1);
echo \"<table border=1 align=center>n\";
echo \"<tr><td>Name</td><td>County</td><td>Sector</td><td>Company Size</td></tr>n\";
while ($myrow = mysql_query($query))
{
printf(\"<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>n\",
$myrow[0], $myrow[1], $myrow[2], $myrow[3]);
}
echo \"</table>n\";
An example of my HTML drop down list code is as follows;
<select name=\"company_size\">
<option value=\"0\" selected>Select Company Size</option>
<option value=\"1\">1 - 9</option>
<option value=\"2\">10 - 49</option>
<option value=\"3\">50 - 250</option>
</select>
No data is being output from the database except the table column headings. I managed to output all the database data in the table before I entered the query so I know the problem lies here.
Any help would be really appreciated.
Sallie-ann