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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:58:51+00:00 2026-06-13T21:58:51+00:00

Hi all i’ve had help from bluefleet (BF) with a mysql query which i’ve

  • 0

Hi all i’ve had help from bluefleet (BF) with a mysql query which i’ve now put in a php file, the query works fine but i find i need to get extra data as well as the count, so what i need is when a match is found i need to look up the username in table tview3.

Whichever table the ip match is found there will be a column called UID, in the table tview3 there will also be a column called USERNAME, what i’d like to do is get the username(s) for the matches and then use them in a text file.

I have to state i’m a complete newbie at this, all help is appreciated

$myquery= "select sum(total)
from
(
    SELECT count(*) as total
    FROM " .TABLE_PREFIX."tview v
    where v.ipaddress = '$ips'
    union all
    SELECT count(*) as total
    FROM " .TABLE_PREFIX."tview2 v1
    where v1.ipaddress = '$ips'
    union all
    SELECT count(*) as total
    FROM " .TABLE_PREFIX."tview3 v3
    where v3.ipaddress = '$ips'
) src";

 $result = mysql_query($myquery);
    $rowCount = mysql_num_rows($result);
    If($rowCount !=0){
       echo "NOT EMPTY";
    }else{
      echo "EMPTY";
    }
   mysql_free_result($result);

$UAM = strtoupper($_SERVER['HTTP_USER_AGENT']);
$ips = strtoupper($_SERVER['REMOTE_ADDR']);
$fp = fopen("logtext.txt", "a");
$DateOfRequest = date('m-d-Y H:i:s');

fwrite($fp, "$DateOfRequest . \nMatched Member: . $username . \nWith User Agent:  . $UAM . \n\nIP: . $ips . \n\n");

So i’d like to populate a variable $username with the username(s) where the matches were found.

Regards,
Silo

  • 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-13T21:58:52+00:00Added an answer on June 13, 2026 at 9:58 pm

    Change:

    SELECT count(*) as total

    to

     SELECT count(*) as total, username
    

    Then you could do something like:

    $row = mysql_fetch_array($query);
    $username = $row['username'];
    

    Hope that helps. Also check out this question for a bit more detail: How do I find the most common result in a column in my MySQL table

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

Sidebar

Related Questions

All, If I run a query like the following: $qry = Select wrong_column from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
All, I'm inserting some text from a textarea in a mySQL database. I'm using
All, How can I bind the array of drop down list items returned from
All, I am building a small site using PHP. In the site, I receive
All, I have the following code: $fetch = mysql_query(SELECT * FROM calendar_events where event_status='booked'
All I need is to create a file that contains a file names' list
All along I've been testing on an Android 2 version ported to x86 (which
All, I have a form with a MultiValueField that almost works. It uses a

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.