関数から2つの結果を返そうとしていますが、最初の結果だけがページに表示されています。
これが私の関数です:
function latestcomment($forum_topics){
$recent = mysql_query(" SELECT created, owner, topic_id
FROM forum_comments
WHERE topic_id = '".mysql_real_escape_string($forum_topics['topic_id'])."'
ORDER BY created DESC
LIMIT 1 ");
$mostrecent = mysql_fetch_array($recent);
$time = $mostrecent['created'];
$name = $mostrecent['owner'];
return $time;
return $name;
}
それから私はこのように呼んでいます
<?php echo latestcomment($forum_topics); ?>
私が呼び出しているテーブルは次のようになります。
+-------+----------+---------------------+------------+
| id | body | created | owner |
+-------+----------+---------------------+------------+
| 1 | hello | 2019-12-01 15:50:27 | name1 |
| 2 | World | 2019-12-01 15:50:32 | name2 |
| 3 | Hi | 2019-12-01 15:51:43 | name3 |
| 4 | Over | 2019-12-01 10:20:30 | name4 |
+-------+----------+---------------------+------------+
また、返された関数のcreated(DATETIME)部分を次のようなものに渡します。
<?php
$date = date_create($forum_topics['$time']) ;
echo date_format($date, 'F j, Y'); echo"<br>";
echo date_format($date, 'g:i A');
?>
1つのクエリのみを使用しますか?
これどうやってするの ?
ありがとうございました。