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
upload image name with extension using php
hi frds..
<input id="file1" type="file" name="file[]" &a
form problem
below in the form action, i've put "test.php?w=$sw&h=$sh" but when i input the for
understanding functions and classes
Code: [Select]
class person {
var $name = "Jimmy Goe";
function get_nam
Values disappear from my array :( HELP!
hey all, I have a lil mysql/php/apache script that queries a database
and pulls put 5 integers.
what business processes?
Hi,
A general question. What business processes (like OTC - Order to Cach, P2P, R2R etc)
How to Create a Dynamic table
col1 col2 date1 date2 date3 date4..........
a b v1 v2 v3 v4
Get content from table into a list, without repeating.
Alright this is kinda an odd thing, so I need some help.
I have a table "quote" wit
I need help on this PHP code
Hi everybody, I made some kind of mistake while editing the code below. As you see, at the 3 row my
Prevention Help
How can I use PHP or any other language (feel free to move this thread) to prevent users doing scree
User information
Hi All,
By using t-code SUIM we get all the user details,if suppose we donot have permission t