Multi line series line graph highcharts showing only one line php mysql
This is my screen shot.
Now when the chooses any of the journal using the checkbox, the graph
should display in the right side, suppose the user selects 3 journals then
3 lines must be shown in the graph.
I have two files 1. anaytics.php 2.get_journ_data.php
Anaytics.php Code
<table id="coauthtable" width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<th align="left">
</th>
<th align="left">
Journal Title
</th>
<th align="left">
Edgefactor
</th>
</tr>
<?php
while($row_journ =
mysql_fetch_array($query_jour)){
$jour_id = $row_journ['jour_id'];
$jour_title = $row_journ['journal'];
$jour_edgefactor =
$row_journ['edgefactor'];
?>
<tr>
<td><input type="checkbox"
name="checkedname[]" value="<?php echo
$jour_id;?>"/></td>
<td >
<?php echo $jour_title;?>
</td>
<td>
<?php echo $jour_edgefactor;?>
</td>
</tr>
<?php
}
?>
Javascript Code:
function submitForm() {
var form = document.myform;
var dataString = $(form).serialize();
$.ajax({
type:'POST',
url:'journal_table/get_data_journ.php',
data: dataString,
success: function(data){
$('#container_journal').html(data);
var options = {
chart: {
renderTo: 'container_journal',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
xAxis: {
title: {
text: 'Year'
},
categories: []
},
yAxis: {
title: {
text: 'Number of Citations'
},
plotLines: [{
value: 0,
width: 1,
//color: '#808080'
}]
},
series: [{
type: 'spline',
color: '#0066FF',
name: 'Citations',
data: []
}]
}
$.getJSON("journal_table/get_data_journ.php", function(data) {
$.each(data, function (key, value) {
options.series[0].data = data;
});
chart = new Highcharts.Chart(options);
});
}
});
return false;
}
get_journ_data.php Code
$hello = $_POST['checkedname'];
//foreach($hello as $key=>$values){
//echo $values;
//}
$result_journ = mysql_query("SELECT year, citations, jour_id FROM
journ_graph WHERE jour_id = '$hello'");
$rows_journ = array();
while($r_journ = mysql_fetch_array($result_journ)) {
$row_journ[0] = $r_journ[0];
$row_journ[1] = $r_journ[1];
array_push($rows_journ,$row_journ);
}
print json_encode($rows_journ, JSON_NUMERIC_CHECK);
The problem is here in the get_journ_data.php file in the query statement,
the $hello variable is not getting the posted value but if I manually
enter the value say 4 like
$result_journ = mysql_query("SELECT year, citations, jour_id FROM
journ_graph WHERE jour_id = '4'");
Then the graph is shown. Where I am going wrong, please help?
No comments:
Post a Comment