Reputation: 115
I have following code. I only get one one row echoed the first one.
What do ido wrong?
<?php
include("/connectdb.php");
$link2=Connection();
$rt = mysql_query("SELECT motion FROM tempLog WHERE Id='13007423' AND DATE(`timeStamp`) = CURDATE() ORDER BY timeStamp DESC LIMIT 2", $link2);
$result = mysql_fetch_row($rt);
if($result)
echo $result[0];
echo $result[1];
?>
Thanks for help!
Upvotes: 0
Views: 125
Reputation: 133370
mysql is deprecated and you should migrate to mysqli or PDO
anyway you shot iterate over the result
while($row = mysql_fetch_row($rt)) {
echo $result[0];
echo '<br />';
}
Upvotes: 0
Reputation: 175
mysql_fetch_row() returns only one line of your query. So you only have an array with your 'mention' variable.
Use this to print all your lines :
$rt = mysql_query("SELECT motion FROM tempLog WHERE Id='13007423' AND DATE(`timeStamp`) = CURDATE() ORDER BY timeStamp DESC LIMIT 2", $link2);
while ($result = mysql_fetch_row($rt)) {
echo $result[0];
}
And please, use mysqli_ . mysql_ is deprecated since php5.5 and removed in php7.0
Upvotes: 2