you cannot close a connection you don’t have (i.e. include the close in the brackets)
help with foreach loop that builds a recordset access database
Collapse
X
-
Well it's done I would like to thank Dormilich and dgreenhouse for all your help. I want to post this for anyone else who has the same problems I had with checkboxes. I left the checkboxes as an html file and posted to this file. You will have to create the table there is a sample above and like Dormilich says create two tables
thanks again
Code:<?php if(isset($_POST['amenity'])) { //Build a where clause based on the form $where = false; foreach($_POST['amenity'] as $amenity) { if(!$where) { $where = 'WHERE a.'. $amenity." = 'y'"; } else { $where .= 'AND a.'. $amenity." = 'y'"; } } $mysqli = new mysqli('localhost', 'root', 'root', 'bnbtest'); $sql =" SELECT bnb.* FROM bnb JOIN amenity as a ON a.bnb_id = bnb.bnb_id $where "; $result = $mysqli->query( $sql ); while ($row = $result->fetch_assoc()) { echo $row['bbName'] . "<br />"; echo $row['url'] . "<br />"; echo $row['phone'] . "<br />"; echo $row['tollFree'] . "<br />"; echo $row['fax'] . "<br />"; echo $row['web'] . "<br />"; echo $row['email'] . "<br />"; echo $row['description'] . "<br />" ."<br />"; } $mysqli->close(); } ?>
Comment
Comment