Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:57:17+00:00 2026-06-13T10:57:17+00:00

I need to know if the last 5 entry’s in a table were placed

  • 0

I need to know if the last 5 entry’s in a table were placed by the same userid (in the code below the user id is frozen_by.

Here’s what I have

//count if the last 5 freezes was placed by the same user

$strFind="SELECT COUNT(*) AS `total` FROM `contest_frozen` WHERE `contest_id`=\"$pid\" AND `frozen_by`=\"$curmemid\" ORDER BY `id` DESC LIMIT 5";
$result=mysql_query($strFind) or die(mysql_error());
$row=mysql_fetch_array($result);
$freeze_total=$row['total'];

if($freeze_total>=5){
//do this
}

if($freeze_total<5){
//do this
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:57:19+00:00Added an answer on June 13, 2026 at 10:57 am

    You could use a query like this: It returns the number of different users in the last 5 rows. It also returns the highest userid, so if UserCount == 1 and MaxUser == $curmemid then you know that that user places the last five records.

    SELECT
      count(distinct frozen_by) as UserCount,
      max(frozen_by) as MaxUser
    FROM 
      contest_frozen
    WHERE 
      contest_id = $pid 
    ORDER BY 
      `id` DESC 
    LIMIT 5
    

    If you need explicit counts, you can do that too. Query below returns the number of records by the given user and the number of records by other users. If ThisUserCount == 5 then all 5 records are from that user.

    SELECT
      sum(case when frozen_by = $curmemid then 1 else 0 end) as ThisUserCount,
      sum(case when frozen_by = $curmemid then 0 else 1 end) as OtherUserCount
    
    FROM 
      contest_frozen
    WHERE 
      contest_id = $pid 
    ORDER BY 
      `id` DESC 
    LIMIT 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The table doesn't have a last updated field and I need to know when
I have a situation where I need to know when the user of a
I need to know how I can replace the last s from a string
I need to know how to exclude files/folders from php generated zip. Here is
I know that last Tuesday: date --date=2 Tuesday But if I need to get
I have an assessment to do, and here's my code so far: number1 =
for our build process i need to know the last changed Revision of each
I am inserting data in multiple tables. I need to know the last inserted
I know the first part of a URL, but need to define the last
Need to know this so that i could send DTMF and that is going

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.