1,105,310 Community Members

how to show recent updates on top

Member Avatar
sultankhan
Junior Poster in Training
50 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

hi evry one may be this a tip task or easy but for me it is not easy i have show.php and showpost.php page in show.php i am showing my picture while in showpost.php i am showing post now if a user add picture it should be on of my home page and if a user post then post should be on top and the picture which have uploaded by first one user just come under this post and so on .....
my code show latest picture on top and also latest post on top but all post are under all picture hope you pepople will understand my problem if you got it please help me
my home page code is

<!---------show picture--->
`<?php include('show.php');?>

<!----------retrive data from post table------->

`<?php include('showpost.php');?>
<!----end of post ---->
<!----retrive data from comments table---->

<?php include('showcomments.php');?> <!-----end of comments------->

and the next problem is that i want if a user post a comments it should came under the related top

thanks in advance please help!!!!!!!!!!!!

Member Avatar
urtrivedi
Posting Virtuoso
1,897 posts since Dec 2008
Reputation Points: 249 [?]
Q&As Helped to Solve: 409 [?]
Skill Endorsements: 27 [?]
 
1
 

if u have timestamp column in ur table then u can order by that column in reverse order

select * from post order by  post_time desc
Member Avatar
sultankhan
Junior Poster in Training
50 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

dear urtrivedi i have two diffrents table for picture and post i have done this but this only show one table on top mean my posts came on top but my picture came below for eaxmaple

post 5 date today
post 4      one day ago
post 3      two day ago
now if a user upload pic it came here
pic 3        today
pic 2        three day ago
pic 1        four day ago

but i want that that pic 3 came under post 5 because the user have upload it just after post 5 hope you will now get my point

Member Avatar
sultankhan
Junior Poster in Training
50 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i have an idea that i keep picture and post in one table but i dont want like that i want to keep in diffrents table.......

Member Avatar
urtrivedi
Posting Virtuoso
1,897 posts since Dec 2008
Reputation Points: 249 [?]
Q&As Helped to Solve: 409 [?]
Skill Endorsements: 27 [?]
 
0
 
select a.show_type, a.id, a.description, a.updatetime from 
(select 'pic' show_type, colpic_id as id, colpic_desc as description, pictime  as updatetime as description from pictable
union 
select 'post' show_type, colpost_id as id, colpost_desc as description, posttime as updatetime from postable) a
order by  a.updatetime desc

now in php code you u can check our custom show_type column

if ($row['show_type']=='pic')
   echo "<img src........>";
else if ($row['show_type']=='post')
    echo $row['description'];
Member Avatar
sultankhan
Junior Poster in Training
50 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

dear where i should keep this code my home.php cod is above and daear what editing i should do in the above code please explaine me because i am not getting it

Member Avatar
urtrivedi
Posting Virtuoso
1,897 posts since Dec 2008
Reputation Points: 249 [?]
Q&As Helped to Solve: 409 [?]
Skill Endorsements: 27 [?]
 
0
 

instead of doing showpost, showpic

you just do all in one query in one file only

Member Avatar
sultankhan
Junior Poster in Training
50 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

dear it not working only post are vissable while picture not i am givivg you details of my tables ok

image 
    ano     aname   adetails    aphoto  aphototype  user1   username    date

post
    id      title   user1   message     timestamp
Member Avatar
sultankhan
Junior Poster in Training
50 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

and if i keep the image page then it show only picture your code i have edit is under

"select a.show_type, a.id, a.description, a.updatetime from
(select 'pic' show_type, colpic_id as id, colpic_desc as description, pictime as updatetime as description from image
 union
 select 'post' show_type, colpost_id as id, colpost_desc as description, posttime as updatetime from post) a
 order by a.updatetime desc";

?>

<?php
if($row['show_type']=='pic')
{?>
   <?php include('showpost.php');?>


<?php    
}
else($row['show_type']=='post') 
?>
 <?php include('show.php');?>
 <?php 

?>
Member Avatar
urtrivedi
Posting Virtuoso
1,897 posts since Dec 2008
Reputation Points: 249 [?]
Q&As Helped to Solve: 409 [?]
Skill Endorsements: 27 [?]
 
0
 

you have to merge show.php and showpost.php in one file

merge 2 qery to one query using union
then one while loop to show contents
use that if condition in that while loop

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article