Jump to content

help with this Select statment...


co.ador

Recommended Posts

I have a mysql error help please?

 

<?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

 

 

Link to comment
https://forums.phpfreaks.com/topic/182326-help-with-this-select-statment/
Share on other sites

thank you maq

 

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

 

<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/>

 

The query is as:

 

$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 ";

 

What about if the user decide to check other checkboxes beside takeout?

 

 

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.

<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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.