diff --git a/SQL UPDATE query.sql b/SQL UPDATE query.sql new file mode 100644 index 0000000..f498d2e --- /dev/null +++ b/SQL UPDATE query.sql @@ -0,0 +1,3 @@ +UPDATE serverlist SET OS = "Linux" WHERE OS LIKE "Linux%"; +UPDATE serverlist SET OS = "AIX" WHERE OS LIKE "AIX%"; +UPDATE serverlist SET OS = "Windows" WHERE OS LIKE "Windows%"; diff --git a/page.php b/page.php index 4fe4660..6f98209 100644 --- a/page.php +++ b/page.php @@ -16,12 +16,16 @@ exit(); } + // Sets sql charset to utf-8 + $mysqli->set_charset("utf8"); + + // Pie: HostType + // Bar: CPUs + // Pie: OS + $i = 0; $hostType = array(); - - // Sets sql charset to utf-8 - $mysqli->set_charset("utf8"); $result = mysqli_query($mysqli, 'SELECT COUNT(HostType) AS "Num" FROM serverlist GROUP BY HostType;'); while($row = mysqli_fetch_row($result)){ @@ -29,6 +33,26 @@ $hostType[$i] = $row[0]; $i = $i + 1; } + + $i = 0; + + $CPUamout = array(); + + $result = mysqli_query($mysqli, 'SELECT COUNT(CPUamount) AS "Num" FROM serverlist GROUP BY CPUamount;'); + while($row = mysqli_fetch_row($result)){ + $CPUamount[$i] = $row[0]; + $i = $i + 1; + } + + $i = 0; + + $OS = array(); + + $result = mysqli_query($mysqli, 'SELECT COUNT(OS) AS "Num" FROM serverlist GROUP BY OS;'); + while($row = mysqli_fetch_row($result)){ + $OS[$i] = $row[0]; + $i = $i + 1; + } ?> @@ -45,10 +69,10 @@ function drawChart() { // Create the data table. - var data = new google.visualization.DataTable(); - data.addColumn('string', 'hostType'); - data.addColumn('number', 'hostTypeCount'); - data.addRows([ + var hostTypeData = new google.visualization.DataTable(); + hostTypeData.addColumn('string', 'hostType'); + hostTypeData.addColumn('number', 'hostTypeCount'); + hostTypeData.addRows([ ['CIT', ], ['DEV', ], ['DR', ], @@ -57,21 +81,61 @@ ['SIT', ], ['UAT', ], ['UNCLASSIFIED', ] + ]); + var CPUamountData = new google.visualization.DataTable(); + CPUamountData.addColumn('string', 'coreNum'); + CPUamountData.addColumn('number', 'coreNumNum'); + CPUamountData.addRows([ + ['1', ], + ['2', ], + ['4', ], + ['8', ], + ['10', ], + ['12', ], + ['13', ], + ['15', ], + ['16', ], + ['24', ], + ['32', ], + ['34', ], + ['40', ], + ['54', ], + ['63', ], + ['64', ], + ['80', ] + ]); + var OSData = new google.visualization.DataTable(); + OSData.addColumn('string', 'OS'); + OSData.addColumn('number', 'OSCount'); + OSData.addRows([ + ['AIX', ], + ['Linux', ], + ['Windows', ] ]); // Set chart options - var options = {'title':'Types of Servers', + var hostTypeOptions = {'title':'Types of Servers', 'width':400, 'height':300}; - + var CPUsOptions = {'title':'Number of Cores', + 'width':500, + 'height':300}; + var OSOptions = {'title':'OS', + 'width':400, + 'height':300}; + // Instantiate and draw our chart, passing in some options. - var pie_chart = new google.visualization.PieChart(document.getElementById('pie_chart')); - var bar_chart = new google.visualization.BarChart(document.getElementById('bar_chart')); + var pie_chart1 = new google.visualization.PieChart(document.getElementById('pie_chart1')); + // Instantiate and draw our chart, passing in some options. + var bar_chart = new google.visualization.BarChart(document.getElementById('bar_chart')); + // Instantiate and draw our chart, passing in some options. + var pie_chart2 = new google.visualization.PieChart(document.getElementById('pie_chart2')); + /* // The select handler. Call the chart's getSelection() method function selectHandler() { var selectedItem = pie_chart.getSelection()[0]; - if (selectedItem) { + if (selectedItem) {e var hostType = data.getValue(selectedItem.row, 1); var hostTypeNum = data.getValue(selectedItem.row, 0); alert('There are ' + hostType + ' machines running as ' + hostTypeNum); @@ -80,17 +144,21 @@ // Listen for the 'select' event, and call my function selectHandler() when // the user selects something on the chart. google.visualization.events.addListener(pie_chart, 'select', selectHandler); - - pie_chart.draw(data, options); - bar_chart.draw(data, options); + */ + + pie_chart1.draw(hostTypeData, hostTypeOptions); + bar_chart.draw(CPUamountData, CPUsOptions); + pie_chart2.draw(OSData, OSOptions); }
- + + +