Find Jobs
Hire Freelancers

MySQL query to display 10 of user's friends sorted by most recently corresponded with friends

$10-30 USD

Completed
Posted over 4 years ago

$10-30 USD

Paid on delivery
I created a small chat box on my website that shows 10 thumbnails for a quick way to open a chat window to communicate with the user's friends. The user may have 1000 friends or more, so the 10 thumbnails should be of most recently communicated with friends. Currently I'm just using a simple query displaying 10 of the user's friends sorted by user's friend's last_activity, which is a timestamp. This can become a problem as the site grows and the user has many friends online, the thumbnails will rearrange every few seconds. <?php $sel = "SELECT friends.user_id, friends.friend_id, [login to view URL], users.user_id, [login to view URL], users.last_activity FROM friends, users WHERE friends.user_id = ".$_SESSION['user_id']." AND users.user_id = friends.friend_id AND [login to view URL] = 2 ORDER BY last_activity DESC LIMIT 12"; $recent_friends = mysqli_query($link,$sel); while($my_friends = mysqli_fetch_array($recent_friends)) { $online_status_msg = "OFFLINE"; $online_status_class = "disconnected"; $onlineStyle="background-color: #ff4f60;"; if(time() - $my_friends['last_activity'] <120) { $online_status_class = "online"; $onlineStyle="background-color: #32e4cd;"; } elseif(time() - $my_friends['last_activity'] <300) { $online_status_class = "away"; $onlineStyle="background-color: #ffd52f;"; } $checkMsgs = mysqli_fetch_array(mysqli_query($link,"SELECT id FROM inbox WHERE user_id = ".$_SESSION['user_id']." AND `author` = ".$my_friends['user_id']." AND `read` = 0 LIMIT 1")); $newMsg=""; if($checkMsgs['id']>0){ $newMsg="newMsg"; }?> <li class="inline-items js-chat-open" data-id="<?=$my_friends['user_id']?>"> <div class="author-thumb"> <img alt="author" src="<?=justGetThumbSource($my_friends['user_id'])?>" class="avatar <?=$newMsg?>" style="max-width:34px;"> <span class="icon-status <?=$online_status_class?>" style="<?=$onlineStyle?>"></span> </div> </li> <? } ?> The `outbox`
Project ID: 21183599

About the project

16 proposals
Remote project
Active 5 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hello hiring member i hope you are doing well i am bhavika i have 4+years experience in php , laravel ,ajax , jquery , javascript , html ,css , bootstrap i have done many things with php , mysql and i can do it and i can start it right now so please give me chance to serve you thanks in advance :)
$25 USD in 1 day
5.0 (205 reviews)
7.4
7.4
16 freelancers are bidding on average $26 USD for this job
User Avatar
This is Pavel who is on discussing with you via chatting. Please drop me a message for further discussion. Thanks.
$20 USD in 1 day
4.9 (96 reviews)
7.0
7.0
User Avatar
CAN COMPLETE WITHIN 1 HOUR. I am a PHP and MySQL expert and have built LOTS of similar systems to yours. I have 5+ years experience with PHP and MySQL. Message me NOW and I can start now.
$50 USD in 1 day
5.0 (88 reviews)
6.5
6.5
User Avatar
Hello, I can help you with this just contact me and let's start the work immediately :)
$20 USD in 7 days
4.7 (101 reviews)
6.1
6.1
User Avatar
i can solve this right now,i can solve this right now,i can solve this right now,i can solve this right now,i can solve this right now,i can solve this right now
$25 USD in 1 day
5.0 (89 reviews)
5.7
5.7
User Avatar
HI, there. I am interested in your task. I have high PHP and Mysql skill and can work anytime. Please contact me and discuss, Thanks.
$20 USD in 1 day
4.9 (31 reviews)
5.4
5.4
User Avatar
Hello :) Thanks for your job posting. I saw your description carefully. I am a Senior web Developer who have 8+ years of experiences. My skills are Html5,CSS,SCSS, Bootstrap,Javascript,Jquery,MySql,PHP especially QUERY is really my type ... I can implement your project with fully and completely. I can help you with my best. I hope that you contact with me. If you need, i will send my live link to you Thank you :)
$50 USD in 1 day
4.9 (34 reviews)
5.4
5.4
User Avatar
Hi, dear! I am glad to bid your project. I have many experiences in website design and development. My rich development experience will give you amazing result for your project. I am serious bidder, so I only bid on projects about which I am confident to deliver 100% total satisfaction to my clients. Please invite me so that we can discuss more details over chat. Thanks. Best regards.
$20 USD in 1 day
4.8 (23 reviews)
4.9
4.9
User Avatar
⭐ Dear Client. ⭐ I have just read your requirements carefully. I am very interested in your project. Although I am new in freelancer, I have more than 5 years of experiences in Database Administration. I'm an expert in MySQL and its data structure. I can finish your project for a short time, perfectly. If you hire me, I'll do my best for you and you'll get a good result for a few days. I guarantee this with my honor, my high skill. I want to discuss with you more details. Thanks, sir Waiting for your reply... Good luck with your business. Best regards.
$30 USD in 2 days
4.3 (29 reviews)
5.6
5.6
User Avatar
I can do in 6 hrs by $20. Hi, I have read your project just before. I am a PHP and MySQL expert with 7+ years of experience. Looking forward hearing from you. Best Regards.
$20 USD in 7 days
5.0 (7 reviews)
3.3
3.3
User Avatar
Dear Hiring Manager. Greetings! I appreciate your posting the job which I am greatly interested in and would like to have the opportunity to discuss your project with you. I just read your description very carefully and am confident that I can provide you successful delivery in time. I have several years of experience in web site development and I have full experienced expertise in MySQL If you feel free to contact me. Regards!
$20 USD in 1 day
3.1 (11 reviews)
5.0
5.0
User Avatar
★★★ Hello SIR ★★★ I have read your project detail carefully. I have ever carried out this kind of project and have rich experiences. I am sure I can handle your project perfectly in the quick timeline. I am a new freelancer, so I am determined to complete it at a low price and a high quality. Of course, you can choose best freelancer and it is your freedom. Opportunity + Effort = Success Now I need a opportunity. If you give me a opportunity, then I will do my best and complete your project perfectly. I will wait for you here, also will ready for you. Thanks, at this point once again warm regards...
$20 USD in 7 days
1.8 (5 reviews)
3.8
3.8
User Avatar
U can just put some condition and it’s gonna be cool. Like if it’s a very close or important person than he should be... Relevant Skills and Experience I use PHP since 2015, and it’s cool like Linux shell
$25 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
Bethel, United States
5.0
4
Payment method verified
Member since Dec 7, 2018

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.