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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:58:46+00:00 2026-05-12T07:58:46+00:00

Below is the current code I use to get the total number of photos

  • 0

Below is the current code I use to get the total number of photos in a DB, An estimated number would even be acceptable as the number of results is just used to determine which folder number I would like to upload into for folder balance of files.

I have a feeling there is a better way then I am using below?

$sql = 'SELECT auto_id FROM friend_user_photo';
$query = executeQuery($sql);
$rowcount = mysql_num_rows($query);

$rowcount returns number of record in the friend_user_photo table

UPDATE:

Isn’t there a way to read information about a database. that might be quicker then using above method or COUNT?

  • 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-05-12T07:58:46+00:00Added an answer on May 12, 2026 at 7:58 am

    You can also use COUNT.

    $sql = 'SELECT COUNT(*) FROM friend_user_photo';
    $query = executeQuery($sql);
    

    This will return a single row containing the number of results. This is also a regular aggregate function so you can do joins, sub queries, conditions (WHERE), grouping and all that good stuff.

    You can also treat this as just another field, so you can alias it and then use it in your joins and sub queries. You can also select additional data, for example:

    $sql = 'SELECT COUNT(*), name FROM table GROUP BY name
    

    This will return a distinct list of names, but will also contain the number of records that exist for each of those names.

    Edit for alternative to count()

    If you don’t want to use COUNT(*) you can also use ‘show table status’. For example:

    $sql = "SHOW TABLE STATUS LIKE 'friend_user_photo'";
    // Note, this LIKE is a regular LIKE, so wild cards can be used
    

    This will return a row with various meta-data including Rows, but also including Key Length (in bytes) and Data Length (in bytes) as well as a lot of other data. This is also usually quite fast since it’s just pulling meta-data as apposed to running an aggregate function like COUNT(*) (so long as the table isn’t locked by another query that’s currently running).

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

Sidebar

Related Questions

I'm having trouble setting a custom back button. Below is the current code I'm
Im trying to generate a color gradient using ColdFusion. My current code below works
The code below is from SAMATE Reference Dataset . I used it to test
Below is the code I use in Chrome extension which gets a url from
i want disable statusbar in activity, i have use below code, it happen SecurityException,
I have got below code to GET dictionary type of session variable value. Please
When I try the below code, I get the output 2 084 001 .
I would like to display the tree structure level by level. My current code
I have a simple bit of jQuery which displays the row below the current
Below you will find my current vHost entry that I am using for 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.