Jump to content

Recommended Posts

Hey there. I am using a really cool PHP script written by Erik Kittel (VERY SIMPLE EVENTS LIST VERSION 1.01) and wanted to see if someone could help me with a modification that I'd like to make. I'd like to somehow modifiy this code so that after an event date has passed, the script will echo something like "no new events at this time" or something else. Right now the script just displays the last event until you enter new events. Thanks!

<?php
include 'config.php';
include 'library/opendb.php';
include 'library/timeFunctions.php';
include 'library/summaryDisplayFunctions.php';

$query = "SELECT * FROM events ORDER BY date, time";
$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))
{
if ($row['date'] >= date('Y-m-d'))
{
displayEvents($row);
}
}


?>
Link to comment
https://forums.phpfreaks.com/topic/11286-help-with-php-event-lister/
Share on other sites

[code]
<?php
include 'config.php';
include 'library/opendb.php';
include 'library/timeFunctions.php';
include 'library/summaryDisplayFunctions.php';

$query  = "SELECT * FROM events ORDER BY date, time";
$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))
{
    if ($row['date'] >= date('Y-m-d'))
    {
displayEvents($row);
    }

// i added this if it works dont no only learning, else if the $row date is less then the date then display old
//messages.

} else {

if ($row['date'] < date('Y-m-d'))
    {
displayEvents($row);
    }
}

?>
[/code]

should really ask the author ok.
[code]
<?php
include 'config.php';
include 'library/opendb.php';
include 'library/timeFunctions.php';
include 'library/summaryDisplayFunctions.php';

$currentdate = date('Y-m-d');
$query = "SELECT * FROM events where date >= '$currentdate' ORDER BY date, time";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if ($num > 0) {
   while($row = mysql_fetch_assoc($result)) {
      displayEvents($row);
   }
} else {
  echo "there are no events at this time";
}
?>
[/code]

or
[code]
<?php
include 'config.php';
include 'library/opendb.php';
include 'library/timeFunctions.php';
include 'library/summaryDisplayFunctions.php';

$query = "SELECT * FROM events ORDER BY date, time";
$result = mysql_query($query);

$count = 0;
while($row = mysql_fetch_assoc($result)) {
   if ($row['date'] >= date('Y-m-d')) {
      displayEvents($row);
      $count++;
   }
}
if ($count == 0) {
  echo "there are no events at this time";
}
?>
[/code]
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.