I have this code to display from my Mysql database.
class cast {
public function fetch_all(){
global $pdo;
$query = $pdo->prepare("SELECT * FROM podcast limit 1");
$query->execute();
return $query->fetchAll();
}
this code does indeed display only 1 result as per the LIMIT 1 bit.
but this diaplays my 1st post.
my posts have a numeric ID under the name of cast_id
How can I get the code above to display the latest addition (for example the highest number in cast_id) and not the first one?
please help.
thank you.
Try something like
class cast {
public function fetch_all(){
global $pdo;
$query = $pdo->prepare("SELECT * FROM podcast ORDER BY cast_id DESC LIMIT 1");
$query->execute();
return $query->fetchAll();
}
That should fetch the latest one.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments