Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Aug 2005
    Posts
    29
    Member #
    10866
    I don't really understand what I am doing wrong here. I am trying to get the sum of a comlumn in my mySQL database, and as far as I know I am doing it correctly. Everything checks out fine if I delete the SUM() function, so there must be a problem there.

    Here is my code:

    PHP Code:

    <?php

    $tot
    =mysql_query('SELECT sum(ticketsipod) FROM members');


    echo 
    "
    <div class='ipodright'><div class='br'><div class='tl'><div class='tr'>
    <font class='rafflefont'> Tickets Purchased:"
    ;

    while (
    $tot1 mysql_fetch_array($tot))
    {
    echo 
    $tot1[ticketsipod];
    }
    ?>

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    When you SELECT SUM, you don't actually get back the same column name. So you need to [minicode]SELECT SUM(ticketsipod) AS ticketsipod[/minicode] in order to be able to use [minicode]$tot1['ticketsipod'][/minicode] to access the SUM value.

  4. #3
    Junior Member
    Join Date
    Aug 2005
    Posts
    29
    Member #
    10866
    Thanks, works perfectly now.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 02:00 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com