Retrieving the 25 most recently added entries from all tables in a MySQL databas


Posted on 16th Feb 2014 07:03 pm by admin

Hello,

The code below works great. It creates a table that shows the 25 most recently added tables to a MySQL database called "sitefeather."

Each one of these tables has the following structure:

Code: id INT(11) NOT NULL auto_increment, site VARCHAR(1000) NOT NULL, action1 BIGINT(9) NOT NULL, action2 BIGINT(9) NOT NULL, createddatetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(id), UNIQUE (site)
I would like to echo a list of "site" and "CURRENT_TIMESTAMP" for the 25 most recently added rows, regardless of which table they are in. This may be tricky since the number of tables is variable. Someone advised me that I would have to use a query involving INFORMATION_SCHEMA.TABLES. How can I do this?

Thanks in advance,

John

Code: echo "<table class="samples">";
$index = mysql_query("select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='sitefeather' order by CREATE_TIME desc limit 25");
while ($row = mysql_fetch_array($index))
{
echo '<tr><td><a href="sitesearch.php?find='.urlencode($row['TABLE_NAME']).'&searching=yes&search=search">'.$row['TABLE_NAME'].'</a></td></tr>';

}
echo "</table>";

No comments posted yet

Your Answer:

Login to answer
309 Like 19 Dislike
Previous forums Next forums
Other forums

Save User Inputs while javascript reloading!
hi..
i have written a PHP code in which i reload the page when user selects a value in dropdown..

Comparing Values
Hi
I'm reading data from a database and this seems to work OK.

Each system has an associat

The repetition structure: the while statement not working
New programming student, have assignment as follows:
A restaurant has 4 lunch combos for custom

How to limit the calls to an API
Hello, in my simple script I call an api which effectively involves me getting an xml file.

H

url- go to webpage
i have an input text field and submit button.

how do i make the url entered into the textfiel

Looping Problem
I've got a client that has a database with about 200 events at any given time. I'm trying to loop t

SAP BCS. BPS
Hi all,

I am seeking reading note on the following in BW

BCS, BPS
ADVANCE

Question about ShowWindow()
Hello....

I'm struggling with sumpin, and I hope y'all can help.

I've got a CFormView

How could I do this?
Ive got a simple lottery game, and am using an sql database to keep track of the numbers bought. But

How to restrict the display of report variants
Hello All,

I want t know how to restrict the display of report variants.
I mean, whe

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash