Hi - I have the following code: <?php // Connects to your Database // Get data from first table $query1 = mysql_query("SELECT * FROM Customers WHERE Datem = CURDATE()") OR die(mysql_error()); // Get data from second table $query2 = mysql_query("SELECT Cubez.*, Customers.Name FROM Cubez, Customers WHERE Cubez.Date1 = CURDATE() AND Customers.Email = Cubez.Email GROUP BY Customers.Name") OR die(mysql_error()); // Get data from third table $query3 = mysql_query("SELECT Topup.*, Customers.Name FROM Topup, Customers WHERE Topup.Datem = CURDATE() AND Customers.Email = Topup.Email GROUP BY Customers.Name") OR die(mysql_error()); $data = array(); // Loop through first table while ($user = mysql_fetch_assoc($query1)) { $data[$user['Time']] = '<img src=images/newmem.png><a class=W8NB> <u>'. $user['Name'] .'</u> Becomes a Member <a class=G7>['. $user['Time'] .']</a>'; } // Loop through second table while ($purchase = mysql_fetch_assoc($query2)) { $data[$purchase['Time']] = '<img src=images/newcube.png><a class=W8NB> <u>'. $purchase['Name'] .'</u> Purchases a Cube (ID #'. $purchase['CubeID'] .') <a class=G7>['. $purchase['Time'] .']</a>'; } // Loop through third table while ($top = mysql_fetch_assoc($query3)) { $data[$top['Time']] = '<img src=images/newtop.png><a class=W8NB> <u>'. $top['Name'] .'</u> Tops Up Cube ID #'. $top['CubeID'] .' £'. $top['Value'] .'.00 <a class=G7>['. $top['Time'] .']</a>'; } // Sort array keys in reverse order krsort($data); foreach ($data AS $time => $action) { echo "{$action} <br />\n"; } ?> PHP: This shows every piece of information stored in the array - How do I limit it to show just the last 5 pieces of information stored???
Cesay, that would be a waste of processing - getting all the records from DB and only using 5. Instead, to the SQL queries, add an "ORDER BY date DESC" or "ORDER BY primary key DESC" if it is an incrementing one and then "LIMIT 5" at the end.
All sorted! Cesay - That was the right way as the array stores information from 3 Different Tables! All sorted