Jump to content

Special offer display script


illuz1on

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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