SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2011
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sql query consolidation

    Hi guys,

    How would i go about querying my sql database and consolidating the results using PHP. For example....

    Table 1 -

    name amount
    person_1 1
    person_2 7
    person_1 4
    person_2 3

    Current query
    PHP Code:
    SQL ' SELECT name, amount FROM table 1'
    $query mysql_query($query) or die (mysql_error());
    while (
    $row mysql_query($query) {
           echo 
    "Name =" $row['name'] .   "Amount =" $row['amount'];

    Obviously that would display the result very similar to the above table. However i want it to consolidate so using the same data it would look like this...

    name amount
    person_1 5
    person_2 10


    Any suggestions how i would go about this??

    thanks in advance.

  2. #2

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2011
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah thanks, easy when you know how. I've bookmarked the page for future ref.

    Thanks again.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •