I'm trying to make the values in the EVENTNAME
array the key of the arrays below it.
I want to be able to do a foreach on on a php variable and get the EVENTNAME
and the count for its IMMIGRATIONS, EFFECTS and SUPPLYCHAINS.
$keyevents = oci_parse($conn, "SELECT EVENTNAME FROM KEYEVENTS GROUP BY EVENTNAME");
oci_execute($keyevents);
oci_fetch_all($keyevents, $keyevent);
$immigrations = oci_parse($conn, "SELECT COUNT(*) IMMIGRATIONS FROM KEYEVENTS LEFT JOIN IMMIGRATION ON KEYEVENTS.EVENTID = IMMIGRATION.EVENTID GROUP BY EVENTNAME");
oci_execute($immigrations);
oci_fetch_all($immigrations, $imm);
$effects = oci_parse($conn, "SELECT COUNT(*) EFFECTS FROM KEYEVENTS LEFT JOIN EFFECT ON KEYEVENTS.EVENTID = EFFECT.EVENTID GROUP BY EVENTNAME");
oci_execute($effects);
oci_fetch_all($effects, $eff);
$supplychains = oci_parse($conn, "SELECT COUNT(*) SUPPLYCHAINS FROM KEYEVENTS LEFT JOIN SUPPLYCHAINS ON KEYEVENTS.EVENTID = SUPPLYCHAINS.EVENTID GROUP BY EVENTNAME");
oci_execute($supplychains);
oci_fetch_all($supplychains, $supp);
$stats = array_merge($keyevent, $imm, $eff, $supp);
highlight_string("<?php
\$stats =
" . var_export($stats, true) . ";
?>");
var_export
array (
'EVENTNAME' =>
array (
0 => 'Brexit',
1 => 'leave date set',
2 => 'leave date ',
3 => 'deal or no deal',
),
'IMMIGRATIONS' =>
array (
0 => '1',
1 => '1',
2 => '1',
3 => '1',
),
'EFFECTS' =>
array (
0 => '2',
1 => '1',
2 => '1',
3 => '2',
),
'SUPPLYCHAINS' =>
array (
0 => '1',
1 => '1',
2 => '1',
3 => '1',
),
)