SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Array Count Question

    Hi,

    I'm trying to return a set of results back so I can output them in a graph plotter.

    The results for a question in this instance will be 0,1,2,3,4,5 or 6 I want to count these and plot them out on a graph.

    So far I'm using the below but it doesn't seem to output as required. Any ideas on another solution?

    PHP Code:
    function getResultsforColleagueQuestion($q$id) {
        
    $db db::getInstance();
            if (
    $result $db->query("SELECT `cq_q1_".$q."` FROM `collegue_questionaire` WHERE `cq_question_number` = 7 AND `cq_user_id` ='" $id "'")) {
                if (
    $rows $db->getrows($result)) {
                        return 
    array_count_values($rows[1]);
                } 
            }
            
        } 

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    #1 what database connection class are you using?
    #2 you need an alternate return value (if there was an error, return -1 or some such)
    #3 why would you count only the 2nd result? ($rows[1]). I think you meant to use array_count_values($rows);
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


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
  •