FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
Arrays and While Mysql Functions
Message  

Reply with quote
Post Arrays and While Mysql Functions 
How can I get this array to work? I am trying to add data to an array for every row of data? This is a sellection of queries that I need to parse into an array so a function can use the arra to draw a graph. I am new to arrays how can I get this to work? Please help?
Code:

      //Sql Query
         //Day Name
         $sql = "SELECT count(*) as cnt, DAYNAME(date) as dnr, TO_DAYS(date) as tdr FROM $dbsql WHERE date >= DATE_SUB( CURRENT_DATE, INTERVAL 6 day ) GROUP BY dnr,tdr ORDER BY tdr";
         $result = mysql_query($sql);
         while ($row = mysql_fetch_array($result)) {
            $comma = ",";
            $xdata .= '"'.$row[dnr].'"'.$comma;
         }
         
         //Data
         $sql = "SELECT count(*) as cnt, DAYNAME(date) as dnr, TO_DAYS(date) as tdr FROM $dbsql
         WHERE date >= DATE_SUB( CURRENT_DATE, INTERVAL 6 day ) GROUP BY dnr,tdr ORDER BY tdr";
         $result = mysql_query($sql);
         while ($row = mysql_fetch_array($result)) {
            $comma = ",";
            $ydata .= $row[cnt].$comma;
         }
         //Trim Extra Commas
            $ydata = substr($ydata, 0, strlen($ydata)-1);
            $xdata = substr($xdata, 0, strlen($xdata)-1);
         
      $y = array($ydata);
      $x = array($xdata);   
      $title = "Unique Hits/Day";
      $labelx = "Day";
      $labely = "Unique Hits";



_________________
We will rule the world!
Oops i dropped my cookie!
http://pegpro.efhost.com I Wish I Game
http://www.sls.r8.org Quick Fun/Games
http://www.pegproandlhsart.com My Buisness
View user's profile Send private message Send e-mail MSN Messenger

Reply with quote
Post  
As far as I understand, you are concatinating your data into a string by your code, but you want it to be populated into an array. This is how you can do it:

Code:

//Sql Query
         //Day Name
         $xdata=array();
         $ydata=array();
         $sql = "SELECT count(*) as cnt, DAYNAME(date) as dnr, TO_DAYS(date) as tdr FROM $dbsql WHERE date >= DATE_SUB( CURRENT_DATE, INTERVAL 6 day ) GROUP BY dnr,tdr ORDER BY tdr";
         $result = mysql_query($sql);
         while ($row = mysql_fetch_array($result)) {
            $xdata[] = $row[dnr];
         }
          
         //Data
         $sql = "SELECT count(*) as cnt, DAYNAME(date) as dnr, TO_DAYS(date) as tdr FROM $dbsql
         WHERE date >= DATE_SUB( CURRENT_DATE, INTERVAL 6 day ) GROUP BY dnr,tdr ORDER BY tdr";
         $result = mysql_query($sql);
         while ($row = mysql_fetch_array($result)) {
            $ydata[] = $row[cnt];
         }
          
      $y = $ydata;
      $x = $xdata;    
      $title = "Unique Hits/Day";
      $labelx = "Day";
      $labely = "Unique Hits";



_________________
www.eb-downloads.com
FREE E-BOOKS DOWNLOADS.
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com