Hi all,
I've been tearing my hair out for days on this as this is my first time coding anything substantial and im on the cusp of breaking through. However, no matter what I try the $POST funtions wont work, I have error reporting on, and im telling it to print the POST variables. I get no errors (which im pleased about) but the print of the $POST says:
Array()
Here is my code:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$hostname = "localhost";
$username = "######";
$password = "#######";
$database = "#######";
$tablename = "Testtable";
$connection = mysql_connect($hostname, $username, $password);
if (!$connection) {
die("A connection to the server could not be established");
}
mysql_select_db($database) or die("Database could not be selected!");
if (isset($_POST['MerchantType']) && isset($_POST['County'])){
$MerchantType = $_POST["MerchantType"];
$County = $_POST["County"];
$result = mysql_query("SELECT * FROM $tablename WHERE County = '$county' AND MerchantType = '$MerchantType' ");
while ($row_details = mysql_fetch_array($result))
{
echo '
<table border="1" bordercolor="#FFCC00">
<style="background-color:#FFFFFF" width="800" cellpadding="3" cellspacing="3">
<tr>
<td width="200" align="left" rowspan="5">Image</td>
</tr>
<tr>
<td width="573" align="left">Name: '.$row_details['MerchantName'].'</td>
</tr>
<tr>
<td height="27" align="left">Telephone: '.$row_details['Telephone'].'</td>
</tr>
<tr>
<td height="27" align="left">Website: '.$row_details['Website'].'</td>
</tr>
<tr>
<td height="54" align="left">Description: '.$row_details['Description'].'</td>
</tr>
</table>';
}
}else{
?>
<form><form name="Results Filter" action="<?php $_SERVER['PHP_SELF']?>" method="POST"> Select Category:
<select name="MerchantType">
<option value="antiques">Antiques</option>
<option value="Bicycles">Bicycles</option>
<option value="B+B's/Hotels">B+B's/Hotels</option>
<option value="Beauty Salons/Hairdressers">Beauty Salons/Hairdressers</option>
<option value="Bookshops">Bookshops</option>
<option value="Bakers/Butchers">Bakers/Butchers</option>
<option value="Car Parts/Garages">Car Parts/Garages</option>
<option value="Clothing">Clothing</option>
<option value="DIY">DIY</option>
<option value="Computers/Electronics">Computers/Electronics</option>
<option value="Florists">Florists</option>
<option value="Furniture/Beds">Furniture/Beds</option>
<option value="Groceries">Groceries</option>
<option value="Garden Centres">Garden Centres</option>
<option value="Gifts/Stationary">Gifts/Stationary</option>
<option value="Jewellers">Jewellers</option>
<option value="Kitchen/Cookware">Kitchen/Cookware</option>
<option value="Model/Hobby Shops">Model/Hobby Shops</option>
<option value="Music">Music</option>
<option value="Newsagents">Newsagents</option>
<option value="Shoe Shops/Shoe Repairs">Shoe Shops/Shoe Repairs</option>
<option value="Toys and Games">Toys and Games</option>
<option value="Travel Agents">Travel Agents</option>
<option selected>Antiques</option>
</select>
County: <select name="County">
<option value="Carlow">Carlow</option>
<option value="Cavan">Cavan</option>
<option value="Clare">Clare</option>
<option value="Cork">Cork</option>
<option value="Donegal">Donegal</option>
<option value="Dublin">Dublin</option>
<option value="Galway">Galway</option>
<option value="Kerry">Kerry</option>
<option value="Kildare">Kildare</option>
<option value="Laois">Laois</option>
<option value="Leitrim">Leitrim</option>
<option value="Limerick">Limerick</option>
<option value="Longford">Longford</option>
<option value="Louth">Louth</option>
<option value="Meath">Meath</option>
<option value="Monaghan">Monaghan</option>
<option value="Offaly">Offaly</option>
<option value="Roscommon">Roscommon</option>
<option value="Sligo">Sligo</option>
<option value="Tipperary">Tipperary</option>
<option value="Waterford">Waterford</option>
<option value="Westmeath">Westmeath</option>
<option value="Wexford">Wexford</option>
<option value="Wicklow">Wicklow</option>
<option selected>Galway</option>
</select>
<input type="submit" value="Search" Name="submit1">
</form>
<?php
}
print_r($_POST);
echo "</body></html>";
?>
</div>
</div>
</body>
The idea is: 2 drop down boxes to filter results from a database at the top of the page above where the results will be. The Results will appear 5 to page (5 of the tables above). But when it comes to just getting the results to filter to start with, I get nothing, except Array ().
Anyone able to shed light on the matter?
Sam