Jump to content

[SOLVED] 5 mysql


dezkit

Recommended Posts

is there a way to only echo the 5 latest mysql rows?

 

<?php
// Make a MySQL Connection
$query = "SELECT * FROM matches"; 

$result = mysql_query($query) or die(mysql_error());


$row = mysql_fetch_array($result) or die(mysql_error());
echo $row['home_team']. " vs ". $row['guest_team'];
echo " : " . $row['result'];
?>

 

please don't tell me the function i should use, instead, edit my code, thank you!!

Link to comment
https://forums.phpfreaks.com/topic/102346-solved-5-mysql/
Share on other sites

Here you go

 

<?php
// Make a MySQL Connection
$query = "SELECT * FROM matches ORDER BY `id` DESC LIMIT 0,5"; 

$result = mysql_query($query) or die(mysql_error());


$row = mysql_fetch_array($result) or die(mysql_error());
echo $row['home_team']. " vs ". $row['guest_team'];
echo " : " . $row['result'];
?>

Link to comment
https://forums.phpfreaks.com/topic/102346-solved-5-mysql/#findComment-524030
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.