Jump to content

multiple checkbox submit - pulling data from SQL to display results


aarondm

Recommended Posts

Hi,

 

having problems getting checkboxes to display all reuslts when a user selects more than one check box say in the category section and one in the location section - see page http://www.partyco.co.uk/event-and-party-venues/ - submit to see reults page:

 

I managed to get it to display reults if the user only seletc either a right or left column option OR one of each - BUT not when thet select multiple categories and one location - and ideas how to do this ? putting it into an array perhaps - but how - new to some of this....

 

here is the code for the reults page:

<?php
$location = $_POST[location];
$category = $_POST[category];
?>

<?php

$Link = mysql_connect("xxxxxxxxx", "xxxxxxxxx", "xxxxxxxx") or die(mysql_error());
mysql_select_db("xxxxxxxx") or die(mysql_error());

// selects db listings when location not given
if (empty($location)) {
$query = "SELECT * FROM venues WHERE category = '$category' order by title";
$result = mysql_query($query) or die(mysql_error());

// selects db listings when category not given
} elseif(empty($category)) {
$query = "SELECT * FROM venues WHERE location = '$location' order by title";
$result = mysql_query($query) or die(mysql_error());

// selects db listings when both given
}else {
$query = "SELECT * FROM venues WHERE category = '$category' and location = '$location' order by title";
$result = mysql_query($query) or die(mysql_error());
}

while($row = mysql_fetch_array($result)){
echo "<div class=\"resultsShort\" style=\"margin-bottom:10px;\">";
echo "<h2 id=\"resultsHeading\">";
echo $row['title'];
echo "</h2>";
echo "<p class\"resultspara\">". nl2br($row['description']). "</p>";
echo "<h4 style=\"margin:5px 0 0 0; padding:0;\">Contact details</h4>";
echo "<p class\"resultspara\">". nl2br($row['contact']). "</p>";
echo "<div style=\"float:left; width:124px; height:40px; margin:10px 15px 0 0;\">";
echo "<a href=\"/party-supplier-resources/email-supplier.php?title=". $row['title']. "&email=" . $row['email']. "&location=" . $row['location']. "&category=" . $row['category']. "\" title=\"contact this venue here\">";
echo "<img src=\"/images/email-supplier.jpg\" width=\"124\" align=\"right\" height=\"35\" alt=\"contact this supplier button\" border=\"0\" /></a>";
echo "</div>";
echo "</div>";
}


?>


<?php include("../include/shareLinks.php"); ?>


<div id="popupContact">
<a id="popupContactClose" title="close this window">close x</a>
<h1>Supplier Directory Enquiry Form</h1>
<?php include("../include/enquiryform.php"); ?>
</div>
<div id="backgroundPopup"></div>


<?php
mysql_close ($Link);
?>

Any help appreciated!

 

Aaron

 

MOD EDIT:

 . . . 

BBCode tags added.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.