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 7940039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:16:07+00:00 2026-06-03T23:16:07+00:00

I have this weird situation that i have encountered for the first time and

  • 0

I have this weird situation that i have encountered for the first time and given my new status in PHP its even more confusing. In the query below the word “asked by” repeats more times than it should. The amount of times it repeats is related to how many entries its not suppose to show i guess.

Code:

$sql = "SELECT DISTINCT 
          allowed_permissions.post_id, 
          client_visit.client_reason, 
          accounts.full_name, 
          client_visit.type 
        from allowed_permissions 
          LEFT JOIN 
            client_visit 
              on allowed_permissions.post_id = client_visit.visit_id 
          LEFT JOIN 
            accounts 
              ON client_visit.system_id = accounts.system_id 
        where    
          allowed_permissions.allowed_to_view = '$uid'";

$result = mysql_query($sql);

$query = mysql_query($sql) or die ("Error: ".mysql_error());

if ($result == "") {
  echo "";
}
echo "";

$rows = mysql_num_rows($result);

if($rows == 0) {

} elseif($rows > 0) {
  while($row = mysql_fetch_assoc($query)) {
    $reason = $row['client_reason'];
    $person = $row['full_name'];
    //Here the asked word gets repeated...
    echo"$reason asked by $person"; 
  }
}
  • 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-03T23:16:08+00:00Added an answer on June 3, 2026 at 11:16 pm

    What’s surprising is that only “asked” is getting repeated… “asked by” would seem more likely. You’re getting a bunch of rows that don’t contain a $reason or a $person so PHP is printing out the literal text and leaving out the variables. If that’s the case, you could get around it by doing something like this:

    if ( ! empty( $reason ) && ! empty( $person ) ) {
        echo $reason . ' asked by ' . $person;
    }
    

    If that fixes it, you should still deal with the bigger problem in your query. It’s clearly not quite right. It’s hard to say how you should fix it without more context. I’m guessing you need to ditch the DISTINCT and implement a GROUP BY clause.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a weird situation. A client of mine has a website having this
Hi this may seem like a weird question, but here's my situation: I have
I have this weird problem with setting up cookies with PHP. Everything worked fine
So, I have this very weird error - Some advanced PHP devs might also
I have a really weird situation. The idea is there is a scroller that
I have this weird situation. I have these two classes: Public Class Entry End
I'm having a very weird situation that is driving me nuts. I have a
I'm having a bit of a weird situation here. I have a form that
I have a weird situation happening that I'm not quite understanding. I have a
Howdy all, I have a weird situation. I have a C++ code that overloads

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.