SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Nov 20, 2009, 13:57 #1
help with this Select statment...
I have a mysql error help please?
PHP Code:<?php
$query3= "SELECT r.restaurantname, z.zip
FROM restaurants r
LEFT OUTER
JOIN zip_codes z ON r.zip = z.zip
WHERE r.takeout, = 1 ";
$result3 = mysql_query($query3, $connection);
$i = 1;
while ($content3 = mysql_fetch_array($result3)) { // line 50
echo "<div class=\"shoeinfo1\">
<img src=\"images/spacer.gif\" alt=\"spacer\" class=\"spacer2\" />
<h2 class=\"infohead\">". $content3['restaurantname'] . "</h2>
<div class=\"pic\"><img class=\"line\" src= '". $content3['image'] ."' alt=\"picture\" width=\"100%\" height=\"100%\" /></div>
</div>";
$i++;
}
if ($i > 1 && $i % 3 == 0 )
{
echo "<div class=\"clearer\"></div>";
}?>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\nyhungry\page2.php on line 50
-
Nov 20, 2009, 14:25 #2
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
i'll make a wager that it's the comma
-
Nov 20, 2009, 14:28 #3
lol it was the comman thank you...
After I have taken out the comma and it works.
I want it to display by zipcode too it will only display if user check takeout I want it to display stores if user check other check boxes and enter a zipcode as well.
The only check box that will work is the takeout check box which is in the WHERE statement.
There are other check boxes as well
Code:<input type="checkbox" name="example" value="eat-in" /><span class="checkboxes23">Eat-in</span><br /> <input type="checkbox" name="example" value="wifi" /><span class="checkboxes23">Wi-Fi</span><br /> <input type="checkbox" name="example" value="buffet" /><span class="checkboxes23">Buffet</span><br /> <input type="checkbox" name="example" value="tv" /><span class="checkboxes23">Tv</span><br /> <input type="checkbox" name="example" value="parking" /><span class="checkboxes23">Parking</span><br /> <input type="checkbox" name="example" value="catering" /><span class="checkboxes23">Catering</span><br /> <input type="checkbox" name="example" value="take-out" /><span class="checkboxes23">Take Out</span><br/>
Code:$query3= "SELECT r.restaurantname, r.image, z.zip FROM restaurants r LEFT OUTER JOIN zip_codes z ON r.zip = z.zip WHERE r.takeout = 1 ";
I want the query above to choose stores according to the zipcoe, name of the store, and type of food as well if choosen by the user. The query right now is limited to retrive the store if users choose take out The zip code is not working either.
Other fields that user use as input besides the checkboxes.
Code:<label for="zipcode">Zip Code:</label> <input id="zipdoce" name="zipcode" class="text" type="text" /> </li> <li> <label for="state">State:</label> <input id="state" name="state" class="text" type="text" /> </li> <li><label for="state">Type of Food:</label> <select name="foodtype" style="width:155px;" > <option value="spanish">Spanish</option> <option>Chinese</option> <option>Italian</option> <option>Russian</option> <option>American</option> <option>Korean</option> <option>Japanese</option> <option>Indian</option> <option>Portuguese</option> <option>French</option> </select>
CREATE TABLE IF NOT EXISTS `restaurants` (
`id` int(1) NOT NULL AUTO_INCREMENT,
`appetizers_id` int(1) NOT NULL,
`restaurantname` varchar(255) NOT NULL,
`image` varchar(100) DEFAULT NULL,
`foodtype` varchar(50) NOT NULL,
`delivery` int(1) NOT NULL,
`eatin` int(1) NOT NULL,
`wifi` int(1) NOT NULL,
`buffet` int(1) NOT NULL,
`tv` int(1) NOT NULL,
`parking` int(1) NOT NULL,
`catering` int(1) NOT NULL,
`takeout` int(1) NOT NULL,
`zip` varchar(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=177 ;
CREATE TABLE IF NOT EXISTS `zip_codes` (
`id` int(1) NOT NULL AUTO_INCREMENT,
`zip` varchar(5) CHARACTER SET utf8 NOT NULL,
`state` char(2) CHARACTER SET utf8 NOT NULL,
`latitude` varchar(10) CHARACTER SET utf8 NOT NULL,
`longitude` varchar(10) CHARACTER SET utf8 NOT NULL,
`city` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`full_state` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `zip` (`zip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5837 ;
any ideas?
Thank you r937
Bookmarks