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

Are sessions secure at all?..
I haven't really gotten into yet, but I was just thinking of something weird..

Lets say you h

Problem assigning value to variable in "IF" function
Does this script makes sense? I am trying to take the value that is set to "authenticat" a

how to remove in php string display
My code is $message="We're looking at developing our website."; $body= "My mess

Not loading image
When this function gets loaded it doesn't load the image just trying to figure out why.

Code:

how do i display data on a page from mysql
1 - do i use this code at the top of each of my page i wish to only alow access if there as been a s

Move array index to end
Hey guys,
Quick question:

I have an array that looks like this:
Code: [Select]$var =

str_replace help
I am thinking str_replace is my only option to filter outputs from my database to convert them to sa

How to assign JS screen.width to ASP.Net variable
I've got this ASP.net routine that gets the cookie value of the screen width, but now I need to chan

Thread in PHP
Thread in PHP
Some basic use and basic code for thread in php
This is my question?

Why doesn't this work? (SSH2)
This is my script:

Code: <?php
$connection = ssh2_connect('213.251.167.109', 22);

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