我制作和Instagram模仿,我需要做一个饲料。我有2张桌子"关注"和"帖子"。
这是"以下"数据库:
这是"帖子"数据库:
以下是我的代码,可以尝试选择用户关注的人并将他们的帖子放入他们的Feed:
<?php
$username = $_SESSION['username'];
$sql = "SELECT username_follow FROM following WHERE follower = '$username'";
$rsu = mysql_query($sql, $conn);
while ($row = mysql_fetch_array($rsu)){
$uername2 = $row[0];
$sql2 = "SELECT pic, `time` FROM `Posts` WHERE username = '$uername2' ORDER BY `Posts`.`id` DESC";
$res = mysql_query($sql2, $conn);
//echo $row[0];
while ($row2 = mysql_fetch_row($res)) {
echo "<br> <br>";
echo "<center>";
echo "<img width='450px' height='450px' src='data:image;base64,".base64_encode($row2[0])."'>";
echo "<br> <br>";
echo "</center>";
}
}
?>
但是如何按时间顺序显示图片?
答案 0 :(得分:1)
加入两个表并按my $parsed_time = str2time($stime);
if (!defined $parsed_time) {
# ... handle this case
} else {
my $dur = $etime - $parsed_time;
...
}
time