illuz1on Posted July 6, 2007 Share Posted July 6, 2007 Hey I have this piece of code which works fine, but when there are no special offers it just displays nothing, I want to get it to say "Watch this space for up and coming offers!" <?php /* Created on: 4/23/2007 */ ?> <? include("db.php"); ?> <?php // Turn off all error reporting error_reporting(0); ?> <html> <body> Special Promotions<br> <br> <a href="display1.php?type=hotel">Hotel</a> | <a href="display1.php?type=conference">Conference</a> | <a href="display1.php?type=restaurant">Restaurant</a> <hr> </body> </html> <?php $type = mysql_real_escape_string($_GET['type']); if (isset($_GET["type"])) { if ($result = mysql_query("SELECT * FROM specialoffer WHERE type = '$type' ")) { if (mysql_num_rows($result)) { while($row = mysql_fetch_array($result)) { extract($row); echo "<br><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td><strong>$title</strong></td> <td width=\"26%\">Special type: <strong>$type</strong></td> </tr> <tr> <td><strong>Validity:</strong> Available from <strong>$fromz</strong> until <strong>$toz</strong></td> </tr> <tr> <td>$description</td> </tr> <tr> <td>Contact <strong>$contactname</strong> on <strong>$contacttel</strong> or email us at <strong>$contactemail</strong></td> </tr> </table> "; } } } } else { echo "Select one of the above options to see the relevant specials!"; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/58683-special-offer-display-script/ Share on other sites More sharing options...
NArc0t1c Posted July 6, 2007 Share Posted July 6, 2007 try: <? include("db.php"); ?> <?php // Turn off all error reporting error_reporting(0); ?> <!-- Created on: 4/23/2007 --> <html> <body> Special Promotions<br> <br> <a href="display1.php?type=hotel">Hotel</a> | <a href="display1.php?type=conference">Conference</a> | <a href="display1.php?type=restaurant">Restaurant</a> <hr> </body> </html> <?php $type = mysql_real_escape_string($_GET['type']); if (isset($_GET["type"])) { $result = mysql_query("SELECT * FROM specialoffer WHERE type='$type'") or die('Error: ' . mysql_error()); if (mysql_num_rows($result) >= 1) { while($row = mysql_fetch_array($result)) { extract($row); echo '<br><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><strong>$title</strong></td> <td width="26%">Special type: <strong>$type</strong></td> </tr> <tr> <td><strong>Validity:</strong> Available from <strong>$fromz</strong> until <strong>$toz</strong></td> </tr> <tr> <td>$description</td> </tr> <tr> <td>Contact <strong>$contactname</strong> on <strong>$contacttel</strong> or email us at <strong>$contactemail</strong></td> </tr> </table> '; } } else { echo 'Watch this space for up and coming offers!'; } } else { echo "Select one of the above options to see the relevant specials!"; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/58683-special-offer-display-script/#findComment-291095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.