Help with arrays
Posted by:
Sir Juice
Date: February 22, 2017 06:37PM
Please help. I just can't figure this out.
I have the following information from a table:
ign, otid, group, pages, points, week_counter, time
Grace, 5327714, 20, 210, 0, 201707, 2017-02-20 03:54:49
Grace, 5327714, 20, 60, 0, 201708, 2017-02-20 23:04:49
Joe, 9917026, 22, 100, 0, 201708, 2017-02-22 17:40:18
Joe, 9917026, 22, 50, 0, 201707, 2017-02-19 21:58:40
I'm trying to find the best way to pass this information to a chart. I have to put it in an IMG SRC tag so it can be used.
The chart is a line graph with one line per person. The x axis is the week_counter and the y axis is the pages.
I need both people (both lines) to be on the same chart. I need this is be variable, as sometimes there could be only 1 person, or 5, or 100 (it's unlimited).
Another issue is the week_counter. In the above example, both people have the same weeks, however, it could happen that one person starts many weeks after the other and could have no data at all for several weeks. I also need this to get all data, which could be 100 weeks of information (the example only shows two weeks).
I'm not sure if it's best to pull all the data in one statement and try to use arrays to separate it, or use multiple sql statements to pull each individual person's data.
I'm currently using this:
$sql = 'SELECT ign
FROM ' . GROUP_MGMT_TABLE . "
WHERE id = $id
ORDER BY ign, week_counter ASC";
I found that serialize() works for a single person:
$urlPortion='array0='.urlencode(serialize($i)).
'&array1='.urlencode(serialize($nameArray)).
'&array2='.urlencode(serialize($pageArray)).
'&array3='.urlencode(serialize($weekArray));
I then grab it with:
$destcount=unserialize($_GET['array0']);
$destNameArray=unserialize($_GET['array1']);
$destPageArray=unserialize($_GET['array2']);
$destWeekArray=unserialize($_GET['array3']);
Any and all help is extremely appriciated. I'm not sure if you need any more info, but I'll be glad to provide more, if so. Thank you.