busnut Posted September 15, 2009 Share Posted September 15, 2009 I'm not entirely sure how to write a subject topic for my problem, so I apologise in advance. What i've got is a specials sql table, that if the current month has a special, then display else display 'no special' msg. In the sql table, i've got a field titled 'month' where by I just enter the month # (ie, 1 for Jan, 5 for May, 10 for Oct etc). The only way I know how to get around this so far is to have 12 fields, numbered 1 to 12, and if there is no speical, leave the 'items' field as blank, thus the bit of code to get it to work, but what I'm wanting if possible for this to be titied up please so I don't have to have 12 records in the db with half of the year empty: $currentmonth=date(n); $products1=mysql_query("SELECT * FROM monthlyspecial WHERE month=$currentmonth"); while($result1 = mysql_fetch_array( $products1)) { $month1=$result1['month']; $items1=$result1['items']; $description1=$result1['description']; $rrp1=$result1['rrp']; $price1=$result1['price']; if ($month1==$currentmonth && $items1=="") echo "<p>Sorry, there is currently no special for ".date(F)."</p><p>Please check again next month</p>"; else { echo " <p><b>$items1</b></p> <p>$description1</p> <p>This special is only valid for the current month!</p> "; } } Link to comment https://forums.phpfreaks.com/topic/174391-if-nothing/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.