Hi, I have a database set up so that I have quite a few tables and articles in them, what I want to do is pull the tables from the database in the order that they were last updated. The problem is that it is the records in the tables that are getting updated and not actually changing hte tables in any way. I have already pulled the info from the database and put it into an array but had no luck. The code I have is below.. thanks..

$db=dbconnect($topic);
$topics_result=mysql_query("show tables from $topic");

while ($my_topic=mysql_fetch_array($topics_result))
{

$topic_test=mysql_query("select time, date from $my_topic[0]");

$topic_dates = mysql_fetch_array($topic_test);

$date_time="$topic_dates[date]$topic_dates[time]$my_topic[0]";

$table_dates[] = $date_time;

}

sort($table_dates);

for ($i=0 ; $i < count($table_dates) ; $i++)
{
echo "$table_dates[$i]<br>";

}

Thanks for any help...

    What about ORDER BY date DESC?

      the problem is that I am trying to order the TABLES and not the fields within the tables. The TABLES themselves have a "creation_time" when you as MYSQL for the details but I donot know how to access that "creation_time" within PHP to order the tables by it.

      and I have tried "order by creation_time" -- doesnt work

        Easy:

        $qrm=mysql_query("show table status");
        while($m=mysql_fetch_object($qrm)) {
          $qrn = mysql_fetch_object(mysql_query("select unix_timestamp('$m->Create_time') AS secs"));
          $arrTables[$m->Name]=$qrn->secs;
        }
        array_multisort($arrTables,SORT_DESC); // PHP 4 this function
        

        So, you will have the data ordered in $arrTables array

          Write a Reply...