So as everyone else I am new to PHP and I have been trying to create an amenity page for a B&B. I need folk to be able to select checkboxes and it fetches the info from the database.
I posted the checkbox list to the ampage and now I need to search the database for the matching records.
so I know I need to write
can someone check to see if I wrote my data base correctly
AMENITY CHECKBOXES
AMPAGE
DATABASE
I posted the checkbox list to the ampage and now I need to search the database for the matching records.
so I know I need to write
Code:
foreach ($_POST['amenty'] as $value) {
$breakfast = what
$bbq
$kitchenette
}
AMENITY CHECKBOXES
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>B and B Association of San Juan Amenities Page</title> <link href="scripts/main.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="mainContent" > <h1 class="headersTitles">Bed and Breakfast Amenities</h1> <div id="mainArticle"> <p> </p> <p class="mainTextLight">Check the Amenities you are interested in and we will show you the Inns with the features you desire.</p> <p class="innTitleLightLeft"> </p> <p class="innTitleLightLeft"> </p> <form id="form1" name="form1" method="post" action="ampage.php"> <div id="amenities1"> <p> <input name="amenity[]" type="checkbox" id="amenity_breakfast" value="breakfast" /> <label for="">Full Breakfast</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_bbq" value="bbq" /> <label for="amenity[]">BBQ Available</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_kitchenette" value="kitchenette" /> <label for="amenity[]">Kitchenette</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_fireplace" value="fireplace" /> <label for="amenity[]">Fireplace</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_internet" value="internet" /> <label for="amenity[]">Internet Access/ WiFi</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_tv" value="tv" /> <label for="amenity[]">Television</label> </p> </div> <div id="amenities2"> <p> <input name="amenity[]" type="checkbox" id="amenity_dvd" value="dvd" /> <label for="amenity[]">DVD / VCR</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_video" value="video" /> <label for="amenity[]">Videos</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_bath" value="bath" /> <label for="amenity[]">Private Bath</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_jacuzzi" value="jacuzzi" /> <label for="amenity[]">Jacuzzi / Jet Tub</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_hotub" value="hotub" /> <label for="amenity[]">Hot Tub</label> </p> </div> <div id="amenities3"> <p> <input name="amenity[]" type="checkbox" id="amenity_massage" value="massage" /> <label for="amenity[]">Massage Available</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_handicap" value="handicap" /> <label for="amenity[]">Handicapped Access</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_child" value="child" /> <label for="amenity[]">Child Friendly</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_pickup" value="pickup" /> <label for="amenity[]">Pickup Services</label> </p> <p> </p> <p> <input name="amenity[]" type="checkbox" id="amenity_pet" value="pet" /> <label for="amenity[]">Pet Friendly</label> </p> </div> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> <input name="Search" type="submit" value="Search" tabindex="170"/> <input name="start" type="submit" value="Start Over" tabindex="180" /> </p> </form> </div> </div> </body> </html>
AMPAGE
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>checkboxes</title>
<link href="scripts/main.css" rel="stylesheet" type="text/css" />
<style type="text/css"></style>
</head>
<body>
<?php
//not sure what I am doing here I know I need to create a loop with a foreach
foreach ($_POST['amenity'] as $value) {
$breakfast;
}
mysql_connect($read, $write);
mysql_select_db($write) or die("Unable to select database");
$select_query="select am_id from amenities" . $POST;
?>
<div id="mainArticle">
<?php
// here are the image and text that needs to come back for each inn
$innID=mysql_result($result, "am_id");
$image1=mysql_result ($result, $row = "image1");
?>
<div id="mainArticleInn3">
<div id="inn3a"><a href = "<?php echo $row['url']; ?>" target="_blank"><img src="innpg/<?php echo $row['image1']; ?>" width="200" height="150" /></a></div>
<div class="lightText" id="innText3">
<p class="innTitleLight"><a href="<?php echo $row['url']; ?>" target = "_blank"> <?php echo $row['bbname']; ?></a></p>
<p class="innPhoneLight"><?php echo $row['phone']; ?></p>
<p class="innPhoneLight"><?php echo $row['tollFree']; ?></p>
<p class="innPhoneLight"><?php echo $row['fax']; ?></p>
<p class="innWebLight"><a href = "<?php echo $row['url']; ?>" target="_blank"><?php echo $row['web'] ?></a></p>
<p class="innWebLight"><a href="<?php echo $row['emailL']; ?>" target="_blank"><?php echo $row['email'] ?></a></p>
<div id="dateMap3"><a href="http://bytes.com/submit/calendar/calendar.html"><img src="logoMB /checkDateW.gif" alt="Check Date" width="60" height="40" align="left" /></a><a href="<?php echo $row['map']; ?>"><img src="logoMB /showOnMapW.gif" alt="Show on Map" width="60" height="40" align="right" /></a></div>
</div>
<div id="inn3b"><a href="<?php echo $row['url']; ?>" target="_blank"><img src="innpg/<?php echo $row['image2']; ?>" width="200" height="150" /></a></div>
<div id="innRating3"><img src="logoMB /<?php echo $row['logo1']; ?>" width="60" height="55" /><img src="logoMB /<?php echo $row['logo2']; ?>" width="60" height="55" /><img src="logoMB /<?php echo $row['logo3']; ?>" width="60" height="55" /><img src="logoMB /<?php echo $row['logo4']; ?>" width="60" height="55" /></div>
<div class="InformationTextLight" id="innMainText3"><?php echo $row['description']; ?>
</div>
<p class="lightText"> </p>
</div>
<form id="form1" name="form1" method="post" action="">
<input type="submit" name="start" id="start" value="Start Over" />
</form>
</div>
</body>
</html>
DATABASE
Code:
-- phpMyAdmin SQL Dump -- version 3.2.5 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Mar 11, 2011 at 04:59 PM -- Server version: 5.1.44 -- PHP Version: 5.3.2 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `sjibb_test` -- -- -------------------------------------------------------- -- -- Table structure for table `amenities` -- CREATE TABLE `amenities` ( `am_id` int(11) NOT NULL, `image1` varchar(50) NOT NULL, `bbName` varchar(50) NOT NULL, `phone` varchar(20) NOT NULL, `tollFree` varchar(20) NOT NULL, `fax` varchar(20) NOT NULL, `web` varchar(50) NOT NULL, `url` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, `emailL` varchar(50) NOT NULL, `map` varchar(50) NOT NULL, `image2` varchar(50) NOT NULL, `logo1` varchar(50) NOT NULL, `logo2` varchar(50) NOT NULL, `logo3` varchar(50) NOT NULL, `logo4` varchar(50) NOT NULL, `description` varchar(4096) NOT NULL, `breakfast` varchar(4) NOT NULL, `bbq` varchar(4) NOT NULL, `kitchenette` varchar(4) NOT NULL, `fireplace` varchar(4) NOT NULL, `internet` varchar(4) NOT NULL, `tv` varchar(4) NOT NULL, `dvd` varchar(4) NOT NULL, `video` varchar(4) NOT NULL, `bath` varchar(4) NOT NULL, `jacuzzi` varchar(4) NOT NULL, `hotub` varchar(4) NOT NULL, `massage` varchar(4) NOT NULL, `handicap` varchar(4) NOT NULL, `child` varchar(4) NOT NULL, `pickup` varchar(4) NOT NULL, `pet` varchar(4) NOT NULL, PRIMARY KEY (`am_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `amenities` -- INSERT INTO `amenities` VALUES(1, '../imagesMB/innpg/argyle.jpg', 'ARGYLE HOUSE', '360-378-4084', '800-624-3459', '', 'www.argylehouse.net', 'http://www.argylehouse.net', 'info@argylehouse.net', 'info@argylehouse.net', '../maps/Argyle.html', '../imagesMB/innpg/argyle1.jpg', '../imagesMB/logoMB/threedoor.gif', '', '', '', 'Enjoy the charm and character of this 1910-vintage Craftsman located only two blocks from downtown and a short walk from the ferry. Nestled on beautiful grounds to ensure the peace and quiet of a country setting. Comfortable well appointed rooms with in-room TV/DVD, plus hot tub, delicious hot breakfast every day, and wireless Internet access. Children and dogs are welcome here! ', 'yes', 'yes', 'no', 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'no', 'yes', 'yes', 'no', 'yes', 'yes', 'yes'); INSERT INTO `amenities` VALUES(2, '../imagesMB/innpg/dragonfly.jpg', 'DRAGONFLY INN', '360-378-4280', '877-378-4280', '360-378-1392', 'www.thedragonflyinn.com', 'http://www.thedragonflyinn.com', 'host@thedragonflyinn.com', 'host@thedragonflyinn.com', '../maps/dragonfly.html', '../imagesMB/innpg/dragonfly1.jpg', '../imagesMB/logoMB/aaa3D.gif', '../imagesMB/logoMB/threedoor.gif', '', '', 'A unique,Japanese-inspired bed and breakfast, promising a secluded, romantic get away on 15 acres of unspoiled Pacific Northwestern woods. Our tranquil rooms include a queen-size bed,Free Wi-Fi,satellite TV/DVD, pulsating 2-headed shower,oversized 2-person air massage tub, and private patio. Dragonfly''s sumptuous Asian fusion gourmet breakfasts and afternoon treats blend the comfortable and the exotic. No children or pets. ', 'yes', 'no', 'no', 'no', 'yes', 'yes', 'yes', 'no', 'yes', 'yes', 'no', 'no', 'no', 'no', 'no', 'no'); INSERT INTO `amenities` VALUES(3, '../imagesMB/innpg/harrison.jpg', 'HARRISON HOUSE', '360-378-3587', '800-407-7933', '360-378-2270 FAX', 'www.harrisonhousesuites.com', 'http://www.harrisonhousesuites.com', 'innkeeper@harrisonhouse.com', 'innkeeper@harrisonhouse.com', '../maps/Harrison.html', '../imagesMB/innpg/harrison1.jpg', '../imagesMB/logoMB/threedoor.gif', '../imagesMB/logoMB/nwBest.gif', '../imagesMB/logoMB/kiss2.gif', '../imagesMB/logoMB/mobil.gif', 'A hilltop retreat one block from the ferry landing. Fully furnished private suites with kitchens, harbor views, fireplaces, and private hot tubs - sleep two to ten in comfort. Gourmet breakfast, afternoon time, and dinner delivered to your suite or in our private café. Retreats, family reunions, and weddings. Pet friendly. NW Best Places. Peoples Choice Awards. One of 40 inns throughout the state, chosen to be featured in Special Places. ', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no', 'yes', 'yes', 'yes'); INSERT INTO `amenities` VALUES(4, '../imagesMB/innpg/hillside.jpg', 'HILLSIDE HOUSE', '360-378-4730', '800-232-4730', '360-378-4715 FAX', 'www.hillsidehouse.com', 'http://www.hillsidehouse.com', 'info@hillsidehouse.com', 'info@hillsidehouse.com', '../maps/Hillside.html', '../imagesMB/innpg/hillside1.jpg', '../imagesMB/logoMB/aaa3D.gif', '../imagesMB/logoMB/threedoor.gif', '../imagesMB/logoMB/kiss2.gif', '../imagesMB/logoMB/mobil.gif', 'Enjoy views of snowcapped Mt. Baker over the blue waters of Friday Harbor from the spacious deck of this contemporary-style inn. Located just 3/4 of a mile from ferries and airport. Our famous homemade Banana Chocolate Chip cookies are always within easy reach. We are triple diamond rated by AAA and triple star rated by Mobil. WIFI Internet access. ', 'yes', 'yes', 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no', 'no', 'no', 'no', 'yes', 'no', 'no'); INSERT INTO `amenities` VALUES(5, '../imagesMB/innpg/intothewoods.jpg', 'INN TO THE WOODS', '360-378-9501', '888-292-9502', '', 'www.inntothewoods.com', 'http://www.inntothewoods.com', 'inntothewoods@rockisland.com', 'inntothewoods@rockisland.com', '../imagesMB/logoMB/showOnMapW.gif', '../imagesMB/innpg/intothewoods1.jpg', '../imagesMB/logoMB/threedoor.gif', '', '', '', 'Luxurious amenities and furnishings in this new bed breakfast. Suite includes outdoor private deck with Jacuzzi spa, interior Jacuzzi tub & separate shower. All rooms have private phones, VCR and satellite TV with cordless stereo headphones, guest robes, hair dryers & chocates. Comfortable great room with outdoor deck overlooking lake, Web access, books, magazines, games, movies. Afternoon tea daily. Guest Quarters separated from Innkeeper quarters.', 'yes', 'yes', 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no', 'no', 'no', 'no', 'no', 'yes', 'no'); INSERT INTO `amenities` VALUES(6, '../imagesMB/innpg/kirk.jpg', 'KIRK HOUSE', '360-378-3757', '800-639-2762', '', 'www.kirkhouse.net', 'http://www.kirkhouse.net', 'info@kirkhouse.net', 'info@kirkhouse.net', '../imagesMB/logoMB/showOnMapW.gif', '../imagesMB/innpg/kirk1.jpg', '', '', '', '', 'Historic Craftsman style home built in 1907 with twelve foot ceilings, wood-wrapped arched doorways, leaded glass and granite fireplaces and also modern conveniences like wireless internet access and TV/DVD in each room. Four rooms, each with private bath and private entry. Morning breakfast and afternoon snacks. Quiet in-town location with an easy walk to shops and restaurants. ', 'yes', 'yes', 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no', 'no', 'no', 'no', 'no', 'no'); INSERT INTO `amenities` VALUES(7, '../imagesMB/innpg/olympic.jpg', 'OLYMPIC LIGHTS', '360-378-3186', '888-211-6195', '360-378-2097', 'www.olympiclights.com', 'http://www.olympic.com', 'olympiclights@rockisland.com', 'olympiclights@rockisland.com', '../imagesMB/logoMB/showOnMapW.gif', '../imagesMB/innpg/olympic1.jpg', '', '', '', '', '1895 Victorian Farmhouse located on the sunny south end, near American Camp (National Park). Peaceful meadow setting on 5 acres with panoramic views of the sea and the Olympic Mountain Range. 4 rooms with private baths - two with water views. Full breakfast served with eggs from our resident hens. 5 1/2 miles from ferry.', 'yes', 'no', 'no', 'yes', 'no', 'no', 'no', 'no', 'yes', 'no', 'no', 'no', 'no', 'no', 'no', 'no'); INSERT INTO `amenities` VALUES(8, '../imagesMB/innpg/slowSeasons.jpg', 'WHARFSIDE B & B', '', '360-378-5661', '', 'www.slowseason.com', 'http://www.slowseason.com', 'wharfside@rockisland.com', 'wharfside@rockisland.com', '../imagesMB/logoMB/showOnMapW.gif', '../imagesMB/innpg/slowSeasons1.jpg', '', '', '', '', 'Experience Friday Harbor afloat, aboard an enchanting 60 ft. Ketch rigged motor sailor in the tradition of European floating Inns. This elegant vessel has two spacious private romantic staterooms, queen size beds, DVD, WiFi and full gourmet breakfast. Stay with us for your special occasions and experience the islands with a morning cruise to Seal Rock or enjoy relaxing on deck with a breathtaking view of Friday Harbor''s waterfront.', 'yes', 'no', 'no', 'no', 'no', 'no', 'no', 'no', 'yes', 'no', 'no', 'no', 'no', 'yes', 'no', 'no'); INSERT INTO `amenities` VALUES(9, '../imagesMB/innpg/stateInn.jpg', 'STATES INN AND RANCH', '360-378-6240', '866-602-2737', '360-378-6241 FAX', 'www.stateinn.com', 'http://www.stateinn.com', 'ranch@stateinn.com', 'ranch@stateinn.com', '../imagesMB/logoMB/showOnMapW.gif', '../imagesMB/innpg/statesInn1.jpg', '../imagesMB/logoMB/aaa3D.gif', '../imagesMB/logoMB/threedoor.gif', '../imagesMB/logoMB/kiss2.gif', '', 'Rooms and suites on a 60 acre working ranch. All private baths. Feed our sheep and alpacas; visit our chickens. Scratch breakfast with local foods from local farms, eggs from our own pasture raised eggs and our own award-winning jams and jellies. Free WiFi. Comfortable common areas. We welcome reunions and family gatherings. Handicapped units available. Country store features gifts, homemade lunch, fresh bread and local ice cream.', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no', 'yes', 'no', 'no', 'no', 'yes', 'yes', 'yes', 'no'); INSERT INTO `amenities` VALUES(10, '../imagesMB/innpg/trumpeter.jpg', 'TRUMPETER INN', '360-378-3884', '800-826-7926', '360-378-8235 FAX', 'www.trumpeterinn.com', 'http://www.trumpeterinn.com', 'swan@trumpeterinn.com', 'swan@trumpeterinn.com', '../imagesMB/logoMB/showOnMapW.gif', '../imagesMB/innpg/trumpeter1.jpg', '../imagesMB/logoMB/aaa3D.gif', '../imagesMB/logoMB/threedoor.gif', '../imagesMB/logoMB/kiss2.gif', '', 'Contemporarily furnished Inn on 5 serene acres. Offering more than just beautiful bedrooms & gourmet breakfasts. Personalized vacation planning & WIFI. Pick•up service at ferry/airport. On site private massage studio. Gardens for reading, bird-watching or just relaxing. Soaking tub set under the stars. Two separate den to read or watch TV & movies. Private decks for sipping morning coffee or afternoon cocktails.', 'yes', 'no', 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes'); INSERT INTO `amenities` VALUES(11, '../imagesMB/innpg/tucker.jpg', 'TUCKER HOUSE', '360-378-2783', '800-965-0123', '360-378-2270', 'www.tuckerhouse.com', 'http://www.tuckerhouse.com', 'reservations@tuckerhouse.com', 'reservations@tuckerhouse.com', '../imagesMB/logoMB/showOnMapW.gif', '../imagesMB/innpg/tucker1.jpg', '../imagesMB/logoMB/nwBest.gif', '../imagesMB/logoMB/kiss2.gif', '../imagesMB/logoMB/bellHop.gif', '', 'This newly-renovated 1898 Victorian inn with cottages is nestled in a quiet Friday Harbor neighborhood, just 2 blocks from the ferry landing and center of town. All rooms feature private baths, TV/VCRs and a full breakfast. Some rooms and suites have 2 person Jacuzzi tubs, balconies, fire places, kitchenettes and private entrances. Families and pets are welcome in our cottages. Excellent amenities and rates. One of 40 Inns in the state selected to be in the Special PlacesBook. ', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes'); INSERT INTO `amenities` VALUES(12, '../imagesMB/innpg/wildwood.jpg', 'WILDWOOD MANOR', '360-378-3447', '877-298-1144', '360-378-6095', 'www.wildwoodmanor.com', 'http://www.wildwoodmanor.com', 'stay@wildwoodmanor.com', 'stay@wildwoodmanor.com', '../imagesMB/logoMB/showOnMapW.gif', '../imagesMB/innpg/wildwood1.jpg', '../imagesMB/logoMB/threedoor.gif', '', '', '', 'Wildwood Manor is an elegant Queen Anne-style home with breathtaking views of the water and forest. Our eleven tranquil acres feature beautiful gardens and wooded walking paths. Four beautifully appointed rooms with private baths, TV, DVD, and fine amenities. Our three course breakfasts will entice you and get your day off to a delicious start. Endless snacks and refreshments.', 'yes', 'no', 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no', 'no', 'yes', 'no', 'yes', 'no', 'no');
Comment