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

  • Home
  • SEARCH
  • 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 6858593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:10:43+00:00 2026-05-27T02:10:43+00:00

<?php $dbname = ‘pdartist2’; $table = ‘artwork’; $result = mysql_query(select AID, ThumbFilePath, Title, DisplayOrder

  • 0
<?php
    $dbname = 'pdartist2';
    $table = 'artwork';
    $result = mysql_query("select AID, ThumbFilePath, Title, DisplayOrder from artwork where SCID = $SCID order by DisplayOrder") or die(mysql_error());
while($row = mysql_fetch_array($result)){   
    $AID = $row['AID'];
    $ThumbFilePath = $row['ThumbFilePath'];
    $Title = $row['Title'];
    $DisplayOrder = $row['DisplayOrder'];
    $RecordCount = $row['Count']; {
            $ColCount = $ColCount+1;
        if ($ColCount ==5) {
            echo "<div id='clear'></div>";
            $ColCount = 1;
    }
    echo "<div id='thumb' onClick='window.location='gallery_detail.php?AID=AID';' title='Enlarge'>";
    echo "<div id='thumb_container'>";
    echo "<a href='gallery_detail.php?AID=$AID'><img src='/$ThumbFilePath' title='Enlarge' alt='Enlarge' border='0'></a>";
    echo "<div id='name_spacer'>";
    ($ColCount);
    echo "<div id='thumbdesc'>$Title</div>";
    echo "</div>";
    echo "</div>";
    echo "</div>";
    }       
}
    mysql_free_result($result);
    ?>

When I run this query it works as it should. The problem arises when I add the COUNT(). I need to have something like this:

$result = mysql_query("select AID, ThumbFilePath, Title, DisplayOrder, COUNT(*) AS RecordCount from artwork  where SCID = $SCID order by DisplayOrder") or die(mysql_error());   

But the result from that query is not what it should be.

  • 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-27T02:10:44+00:00Added an answer on May 27, 2026 at 2:10 am

    I think you want to have the total row count, but COUNT(*) automatically groups them together.

    Consider using a subquery.

    $result = mysql_query("select AID, ThumbFilePath, Title, DisplayOrder, (SELECT COUNT(*) FROM artwork WHERE SCID=$SCID) ResultCount FROM artwork  where SCID = $SCID order by DisplayOrder") or die(mysql_error());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having difficulties to display data from mysql database to PHP generated table. Interesting
SELECT * FROM dbname WHERE text = 'a%' (this can get all the `text`
I have a php page that pulls data from a mysql database based on
I am exporting a SQL Server table to a CSV using php (see code
I am having difficulties sending the UDID from the iPhone to a PHP script
the following short test script <?php define('DBHOST', '/tmp'); define('DBNAME', 'XXX'); define('DBUSER', 'XXX'); define('DBPASS', 'XXX');
Here is my PHP code, it's getting a listing of collections from mongodb $list
Static variable gotcha in php I am from Java background and have switched to
This is what I do in php: $dbhandler = new PDO('mysql:host='.domain.':'.port.';dbname='.dbName.';',db_user,db_password); $stmt = $dbhandler->prepare(INSERT
<?php /** Connect to DB */ mysql_connect(localhost, dbuser, pass) or die(mysql_error()); mysql_select_db(dbname) or die(mysql_error());

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.