php - Sort by date from different table -
i need help. please me out work.
i have these 2 tables, relation
between them user_id
. accomplished select follow , display images wall. however, have strange issue: photos sorted desc
want, sorted user_id
. means whoever follow first, image sorted first desc
.
i tried every possible way photos sorted base on desc
newest photo top, couldn't. here tables , i'll show every possible thing tried:
create table if not exists `photos` ( `id` int(11) not null auto_increment, `img` varchar(255) not null, `about` text not null, `date` varchar(222) not null, `user_id` varchar(255) not null, `likes` int(255) not null, `down` int(255) not null, primary key (`id`) ) ; create table if not exists `follow` ( `id` int(11) not null auto_increment, `followers` varchar(255) not null, `following` varchar(255) not null, primary key (`id`) }
one
followers_photo.php, retrieve following id
from:
$the_user = mysql_query("select * users username = '$getuser'"); $tuser=mysql_fetch_array($the_user); $tu_id = $tuser['id']; $followers = mysql_query("select distinct follow.* follow join photos on (follow.followers = $tu_id) order photos.date desc"); $f_s_count = mysql_num_rows($followers);
- index.php display images here.
while($uim = mysql_fetch_assoc($followers)){
$i_id = $uim['following']; $followers_image = mysql_query("select distinct photos.* photos join follow on (photos.user_id = $i_id) group rand() order date desc");
the above working, mentioned sorts images based on date desc
, user_id
don't want. want stop sorting image based on user_id
two
followers_photo.php
$the_user = mysql_query("select * users username = '$getuser'"); $tuser=mysql_fetch_array($the_user); $isuser = mysql_num_rows($the_user); $tu_id = $tuser['id']; $tu_name =$tuser ['username']; ////users whos following me $followers = mysql_query(" select distinct follow.* photos join follow on follow.followers = photos.user_id follow.followers = $tu_id order photos.date desc"); // $f_s_count = mysql_num_rows($followers);
index.php
while($uim = mysql_fetch_assoc($followers)){ $i_id = $uim['following']; $followers_image = mysql_query("select * photos user_id = '$i_id' order date desc ");
the above same in first step. point me right way? sort photos people follow based on date desc
, posts last comes first. guys, appreciate lot. , sorry bad english.
Comments
Post a Comment