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
19
Other forums
Interpret Order
Hello all,
I'm wondering if I have this:
Code: $switch = array(
'one' =>
Big Problem!! Please help
Hi Guys,
Im making a website for a friend have encountered a really annoying problem. When ev
comparing tables across databases sql refinement ideas required
Hi all
Via pl/sql I need to ensure that data between tables in different databases match
search function
HI guys,
if anyone could point us in the right direction of how to do this, or provide some t
help with contest script
I would like to code a contest script to my site but i don't know how. Could someone just give me pu
Vertical Alligning - Not working in 1 cell?
<?php
echo "<table id="valign" width="60%" style=
New Login Script
Hi all, i attempted to create a whole new login script witch isnt working for some reason i dont kno
Count of reciepients in php mailer
How can i sent a mail to large no of reciepients say 10,00,00 Using PHP MAILER
how to timeout $doc = new DOMDocument()->load($url)
I am currently using this $doc->load($url) to fetch an rss feed.
If a feed takes long than
Customizing message/behavior
Hi,I'm using the ASP.NET membership/authorization controls in my application. Some parts of my appli