[Solved] Select the newest data in an SQL table? [closed]


first, please dont use ‘date’ as your field name, lets say you rename it as news_date. How about this?

<?php 
$query = mysql_query ("SELECT * FROM yourtable ORDER BY id DESC LIMIT 3");
$number = 1;
while ($result = mysql_fetch_array($query)) { 
    $id = $result['id'];
    $title = $result['title'];
    $news_date = $result['news_date'];
    $post = $result['post'];
?>
    <div name="title"><?php echo $title; ?></div> || <div name="news_date"><?php echo $news_date; ?></div>
    <p>News <?php echo $number; ?></p>
    <p><?php echo $post; ?></p>
 <?php   
    $number++;
    }
?>

6

solved Select the newest data in an SQL table? [closed]