Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6620981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:10:43+00:00 2026-05-25T21:10:43+00:00

I’m trying to make a bar chart for a mobile devices that submit data.

  • 0

I’m trying to make a bar chart for a mobile devices that submit data. Every minute, each mobile device sends a packet of data to the web server – where it’s then stored in a MySQL database. Each mobile device is assigned an IP addresses, and each IP address can send data multiple times a minute (sometimes as many as 10). Here is what an example table would look like:

date_received | bytes | IP address
----------------------------------
1314831600    | 100   | 1482747555
1314831600    | 990   | 1482747555
1314831600    | 074   | 1482747555
1314831660    | 420   | 1482747555
1314831660    | 183   | 1482747555

So you can see that one IP address can submit multiple times a minute over a span of hours (therefore multiple minutes). How would I create an associative array that looked like this:

array
(
   1314831600 = array
                (
                   1482747555 => 100,
                   1482747555 => 990,
                   1482747555 => 074
                );
   1314831660 = array
                (
                   1482747555 => 420,
                   1482747555 => 183
                );
);

The first key would be the date_received value, and the the IP addresses which are sent for that time (with their corresponding bytes values). I’m using CodeIgniter and I thought about populating arrays in my foreach database loop, but wasn’t quite sure how best to do this. Does anybody have any advice?

N.B: I need to keep database calls to a minimum because some tables contain hundreds of thousands of values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:10:44+00:00Added an answer on May 25, 2026 at 9:10 pm

    You cannot share array keys like that (ip address) as they will be overwritten. You can do something like:

    $packets = array();
    while ($row = mysql_fetch_assoc($res)) {
        $packets[$row['date_received']][] = 
            array('ip_address'=>$row['ip_address'], 
            'bytes'=>$row['bytes']
        );
    }
    

    Then you can loop through the data with:

    foreach ($packets as $date => $info) {
        echo "date = $date, ip = $info[ip_address], bytes = $info[bytes]";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.