Thread: PHP Question

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    2
    Rep Power
    0
    I'm making a reports section for a psychic chat website for my sister... It is supposed to distinguish how many transaction numbers each psychic validated, total $$ per psychic, and total $$/pins all together.
    I remember reading something about adding values up per ID, but i can't
    find it.

    Basically do i make call all the values in X table, add those values up (some will be $$, some will be total # of values) for each psychic ID?

    I'd really appreciate the help, i'm very new to this but am completely psyched about learning more. I started from a few online tutorials and i just bought a Sam's 24 hour PHP4 less and have 3 other books i am going to buy from amazon.

    Thank-Q
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    35
    Rep Power
    14
    I don't recommend u to buy so much books, u should read some tutorial on web and codes written by someone else. When u encounter a question, refer to manual, if manual don't help, here is a right place.

    >>total $$ per psychic, and total $$/pins all together.

    For your question, I am confused about it. Can you express it clear?

    Sorry, my mother tongue is not English.

    ------------------
    Good Good Study
    Day Day Up

    [This message has been edited by xiaoguiwxd (edited September 27, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    2
    Rep Power
    0
    I did this one tutorial that was from webmasterbase.com "How to build a database driven site with PHP and MySQL" and learned almost everything I needed. However, after looking at other tutorials i only became confused because everyone does stuff their own way. I figure the book i have now will teach me better and then i just need a referecence book.

    Ok, i'll try to explain myself better. I have a good friend from Switzerland and I know how hard it can be for her to understand some of my gibber-gabber. lol

    Say I have 10 employees and a database containing each employee ID, each $$ amount of each sale they make, and each type (product) they have sold. Now, I want to be able to report this in a webpage and have totals. Lets say we sell computers, software, and tech support.
    I want to know:
    - how many computers did each person sell, and how much software did they sell,etc
    - how much $$ in computers they sold, $$ in software, etc
    - how much $$ have they made all together
    - how many items have they sold

    I think this maybe easier to understand than my psychic thing. This is the same idea, just using other terms. I think i might go try starting this, I can get it to look through each ID, but i may have a problem pulling the sale type out of the sale type column and adding $ values from the money column.

    Thakns again!
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    gg,

    Assuming you have different records for each sale and those records would look like this:

    employee_id
    product_type
    quantity
    item_price

    You could do this query:

    select employee_id,product_type,sum(quantity) as items,sum(quantity*item_price) as revenue from tablename group by product_type,employee_id order by employee_id;

    This will return records containing the total for each product_type/employee. Like:

    employee_id | product_type | items | revenue
    0001 software 4 150.96
    0001 computers 2 1199.96
    0002 software 1 33.99
    0002 computers 3 2017.56


    You can have PHP add the items and revenue for each employee to get totals or run another query and group just by employee_id and not product_type.

    HTH
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    35
    Rep Power
    14
    Suppose u have two product category: computer and software, and a lot of product type of each category, maybe:
    product_id product_name---- computer software
    1------------IBM RS/400-----------Y
    2------------Office97----------------------------Y
    3------------NortanAntivirus-------------------- Y
    4------------Compaq----------------Y
    5------------Legend(China)-------- Y
    ..........................
    and so on.

    Create a table product , like:
    pdt_id--------pdt_name--------pdt_catgory-------per_price
    1------------IBM RS/400----------1---------------- 45.00
    2------------Office97----------------2----------------30.60
    3------------NortanAntivirus--------2----------------400.60
    4------------Compaq--------------- -1---------------- 10.40
    5------------Legend(China)------- 1---------------- 324.90
    1 for computer , 2 for software

    create a table employee, like:
    ely_id ely_name .. and some thing you favor
    1---- you---------...
    2---- me----------...
    3---- he-----------...
    4---- her---------...
    5---- it------------ ...


    create another table sell_record to record every sell , like rod k posted
    ely_id--ptd_id--quantity- per_price--------date
    1--------1--------1-------- 45.00---------2000-9-10
    1--------4--------3--------400.60--------2000-9-12
    2-------- 3---------1--------45.00--------2000-9-15
    1-------- 1---------4--------45.00-------- 2000-10-10


    You want to know:
    - how many computers did each person sell and how much
    select sr.ely_id,sum(sr.quantity) as compter , sum(sr.quantity*sr.per_price) as "total earn($)"
    from sell_record sr, product pd
    where sr.ptd_id = pd.pdt_id and pd.category=1
    group by sr.ely_id

    - how many software did each person sell and how much
    select sr.ely_id,sum(sr.quantity) as software , sum(sr.quantity*sr.per_price) as "total earn($)"
    from sell_record sr, product pd
    where sr.ptd_id = pd.pdt_id and pd.category=2
    group by sr.ely_id


    - how much $$ have they made all together and how many items have they sold
    select ely_id,sum(sr.quantity) as "total items" ,sum(quantity*per_price) as "total earn($)"
    from sell_record
    group by ely_id

    rod k 's
    select employee_id,product_type,sum(quantity) as items,sum(quantity*item_price) as revenue from tablename group by product_type,employee_id order by employee_id;
    solved every thing!

    [This message has been edited by xiaoguiwxd (edited September 27, 2000).]

Similar Threads

  1. PHP MySQL question
    By spookymark in forum PHP Development
    Replies: 1
    Last Post: February 17th, 2004, 12:07 AM
  2. PHP and Table Relationship question
    By spank in forum PHP Development
    Replies: 4
    Last Post: February 9th, 2004, 08:24 PM
  3. SSL & PHP together question?
    By asedesigns in forum Apache Development
    Replies: 1
    Last Post: February 7th, 2004, 09:35 PM
  4. PHP Mailing list Question
    By byte me in forum PHP Development
    Replies: 3
    Last Post: January 23rd, 2004, 06:55 AM
  5. Php + Flash Question
    By ORANGE900 in forum PHP Development
    Replies: 0
    Last Post: January 23rd, 2004, 01:23 AM

IMN logo majestic logo threadwatch logo seochat tools logo