I have the following PHP code
<?php
// SimpleHTMLDom Library
require_once('simple_html_dom.php');
// Source Data
$source = 'table-array-data.htm';
// Displays Extra Debug Info
$dbg = 1;
// Read DOM
$html = file_get_html('http://www.ercot.com/content/cdr/html/real_time_system_conditions');
// get the table. Maybe there's just one, in which case just 'table' will do
//$table = $html->find('#theTable');
// initialize empty array to store the data array from each row
$theData = array();
// loop over rows
foreach ($html->find('table') as $table) {
}
foreach($table->find('tr') as $row) {
// initialize array to store the cell data from each row
$rowData = array();
foreach($row->find('td') as $cell) {
// push the cell's text to the array
$rowData[] = $cell->plaintext;
}
// push the row's data array to the 'big' array
$theData[] = $rowData;
}
var_dump($theData);
?>
Which outputs ->
array
0 =>
array
empty
1 =>
array
0 => string 'Last Updated Oct 31 2011 16:57:00 CDT' (length=37)
2 =>
array
empty
3 =>
array
0 => string 'Current Frequency' (length=17)
1 => string '59.984' (length=6)
4 =>
array
0 => string 'Instantaneous Time Error' (length=24)
1 => string '-0.558' (length=6)
5 =>
array
empty
6 =>
array
0 => string 'Actual System Demand' (length=20)
1 => string '33882' (length=5)
7 =>
array
0 => string 'Total System Capacity (not including Ancillary Services)' (length=56)
1 => string '37155' (length=5)
8 =>
array
0 => string 'Total Wind Output (hourly average)' (length=34)
1 => string '1355' (length=4)
9 =>
array
empty
10 =>
array
0 => string 'DC_E (East)' (length=11)
1 => string '-261' (length=4)
11 =>
array
0 => string 'DC_L (Laredo VFT)' (length=17)
1 => string '0' (length=1)
12 =>
array
0 => string 'DC_N (North)' (length=12)
1 => string '0' (length=1)
13 =>
array
0 => string 'DC_R (Railroad)' (length=15)
1 => string '0' (length=1)
14 =>
array
0 => string 'DC_S (Eagle Pass)' (length=17)
1 => string '1' (length=1)
Now I'm trying to get those array values into mysql. Just trying to figure out how to assign it. I know [14][0] = DC_S (Eagle Pass)
I'm just not sure how to use those values to put them in mysql.
Anyhelp would be appreciated.
Tahnks