if ($Event == "99")
  {
    //----- SPECIAL EVENT -----
    //Add event to RecentEvents column
    $RecentEvents = "";
    $query = mysqli_query($dblink, "SELECT RecentEvents FROM tblMyTableName WHERE SomeField = $SomeField");
    if ($result = mysqli_fetch_array($query, MYSQLI_ASSOC))
      $RecentEvents = $result['RecentEvents'];    //RecentEvents is a comma seperated string array

    $RecentEventsValuesArray = explode(",",$RecentEvents);

    $RecentEventsWrite = "[Something happened " . date("Y-m-d H:i:s") . "]";
    for ($Index = 0; $Index < 9; $Index++)          //<<<<<<<<Limit the number of old events we keep
    {
      if ($Index >= count($RecentEventsValuesArray))
        break;
      $RecentEventsWrite .= "," . $RecentEventsValuesArray[$Index];
    }

    mysqli_query($dblink, "UPDATE tblMyTableName SET
        RecentEvents = '$RecentEventsWrite'
      WHERE SomeField = $SomeField
      ");
  }
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.