Hi,
I am having a problem with the following script, it allows a user to search for suppliers in a given county. The problem is the search is not executing, I have tried printing the query and error reporting but it is not working at all, any ideas?
<html>
<form name="form" action="<?=$_SERVER["PHP_SELF"]?>" method="get">
<p>County:
<name="q" </td><td>
<?php
//$currentvalue0=$row['county'];
$counties = array('Anglesey', 'Angus', 'Argyll', 'Avon', 'Ayrshire', 'Banffshire', 'Bedfordshire', 'Berkshire', 'Berwickshire', 'Borders', 'Buckinghamshire', 'Bute', 'Caithness', 'Cambridgeshire', 'Central Scotland', 'Cheshire', 'Clackmananshire', 'Cleveland', 'Clwyd', 'Cornwall', 'County Antrim', 'County Down', 'County Durham', 'County Fermanagh', 'County Londonderry', 'County Tyrone', 'Cumbria', 'Denbighshire', 'Derbyshire', 'Devon', 'Dorset', 'Dumfries and Galloway', 'Dunbartonshire', 'Durham', 'Dyfed', 'East Ayrshire', 'East Lothian', 'East Sussex', 'East Yorkshire', 'Edinburgh', 'Essex', 'Fife', 'Glamorgan', 'Gloucestershire', 'Grampian', 'Greater London', 'Greater Manchester', 'Guernsey', 'Gwent', 'Gwynedd', 'Hampshire', 'Herefordshire', 'Hertfordshire', 'Highlands and Islands', 'Humberside', 'Inverness-shire', 'Isle of Arran', 'Isle of Man', 'Isle of Skye', 'Isle of Wight', 'Jersey', 'Kent', 'Lanarkshire', 'Lancashire', 'Leicestershire', 'Lincolnshire', 'Lochaber', 'London', 'Londonderry', 'Lothian', 'Merseyside', 'Middlesex', 'Moray', 'Nottinghamshire', 'Orkneys', 'Outer Hebrides', 'Oxfordshire', 'Peeblesshire', 'Perthshire', 'Powys', 'Shropshire', 'Somerset', 'South Yorkshire', 'Staffordshire', 'Stirlingshire', 'Strathclyde', 'Suffolk', 'Surrey', 'Sutherland', 'Swansea', 'Tayside', 'Tyne and Wear', 'Warwickshire', 'West Lothian', 'West Midlands', 'West Sussex', 'West Yorkshire', 'Wester Ross', 'Wiltshire', 'Worcestershire');
echo '<select name="county"><option value="01" />Aberdeenshire';
for ($i=1; $i <= sizeof($counties); $i++)
{
$lz = strlen($i) == 1 ? '0'.$i : $i;
echo '<option value="'.$lz.'" selected />'.$counties[$i-1];
}
echo '</select>';
?>
</p>
<input type="submit" name="Submit" value="Search" />
</form>
<html>
<?php
$var = @$_GET['q'] ;
$county = trim($var); //trim whitespace from the stored variable
// rows to return
$limit=10;
// check for an empty string and display a message.
if ($county == "")
{
echo "<p>Please enter a search...</p>";
exit;
}
// check for a search parameter
if (!isset($var))
{
echo "<p>Please enter a search</p>";
exit;
}
$query = "select county, supplierid, username from suppliers where county =\"$trimmed\" order by username";
print $query;
$numresults=mysql_query($query) or die(mysql_error());
$numrows=mysql_num_rows($numresults);
if ($numrows == 0)
{
echo "<h4>Results</h4>";
echo "<p>Sorry, your search: "" . $county . "" returned zero results</p>";
etc, etc
Thanks,
G