Note that there are some explanatory texts on larger screens.

plurals
  1. POMysql returns null for rows that doesn't exist
    text
    copied!<p>I have the following code:</p> <pre><code>while ($row = mysql_fetch_array($result)){ $que ='select SUM(price) from prices_adverts where advert_id="7" and room_type_id="54" and (date &gt;= "2013-09-20" AND date &lt;"2013-09-21") order by price'; $que ='select SUM(price) from prices_adverts where advert_id="7" and room_type_id="55" and (date &gt;= "2013-09-20" AND date &lt;"2013-09-21") order by price'; and etc $res=mysql_query($que) or die(); $rw=mysql_fetch_row($res); $price= $rw['0']; } </code></pre> <p>this returns sum for some records that have prices in the database and NULL for $price for the records dont exist /when a room doesnt has price for specific dates it doesn't exist in the table / So my question is how I can get result for records that exist only??? I do not need NULL values for prices and is it possible to access $price outside while ? How? Please help, thanks</p> <p>May I explain what exactly I need, this may help you to help Me :) Above I am looping hotels rooms to check how much would cost the room for specific period. Than I need to draw button outside loop which will divert visitor to reservation page. But if a hotel has no room prices available for the dates, I wish to have no button for reservation. That's why I need to figure out is there at least 1 room with prices in the hotel or not.. Hope this helps</p> ########################################################Update <p>first query: I am taking all London hotels id-s</p> <pre><code>select id from adverts where town="London" limit 0, 5 </code></pre> <p>than</p> <pre><code>for($i=0;$i&lt;$num_rows;$i++){ $row=mysql_fetch_row($result); echo echo_multy_htl_results($row[0]); } </code></pre> <p>this function echo_multy_htl_results is:</p> <pre><code>select a.article_title, a.town, a.small_image, a.plain_text, a.star_rating, a.numberrooms, rta.room_type_id, rt.bg_room_type,a.longitude, a.latitude, a.link_name, a.id from adverts a, rooms_to_adverts rta,room_types rt where a.id = rta.advert_id and rta.advert_id="3" and rta.room_type_id=rt.id and rt.occupants&gt;="1" group by rt.bg_room_type order by rt.occupants ASC </code></pre> <p>it gets info for the html hotel square and also room_types_id-s and that it comes the cod already added.. What would you suggest ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload