Hello guys.
I am trying to query a mssql database toi build a plot. The thing is that i need multiple bars for each hour. Raw code i mean this (where 100,200,300 are seconds):
$data = array(array('hour 8', 100, 200, 300)));
I am trying to achieve this with the following code:
if i echo $lista i get something like this 100, 200, 300
But if i try to add it like this:
$data = array(array('hour 8', $lista)); it doesn't work. Other way of doing it i don't know. Can you please give me a hint on makeing this work. Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No, it isn't going to work that way because $lista is a string (which happens to contain a comma-separated list of numbers). It's like the difference between array(1, 2, 3) and array("1, 2, 3"). The first makes an array with 3 elements which are numbers, and the second makes an array with a single element which is a string.
You need to show us more information to help. If you are plotting multiple points, and multiple bars per point, then you would have a 2-dimensional data set. But you are only taking 1 column ('d') from your data table. How does this become a 2-dimensional set of values with (row, column) indexes?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello guys.
I am trying to query a mssql database toi build a plot. The thing is that i need multiple bars for each hour. Raw code i mean this (where 100,200,300 are seconds):
$data = array(array('hour 8', 100, 200, 300)));
I am trying to achieve this with the following code:
$query=mssql_query("SELECT ....");
$cici = array();
while( $agrow2 = mssql_fetch_array( $query ) ) {
$cici[] = $agrow2['d'];
}
$prefix = '';
$lista='';
foreach ($cici as $valo)
{
$lista .= $prefix . '' . $valo . '';
$prefix = ', ';
}
if i echo $lista i get something like this 100, 200, 300
But if i try to add it like this:
$data = array(array('hour 8', $lista)); it doesn't work. Other way of doing it i don't know. Can you please give me a hint on makeing this work. Thanks!
No, it isn't going to work that way because $lista is a string (which happens to contain a comma-separated list of numbers). It's like the difference between array(1, 2, 3) and array("1, 2, 3"). The first makes an array with 3 elements which are numbers, and the second makes an array with a single element which is a string.
You need to show us more information to help. If you are plotting multiple points, and multiple bars per point, then you would have a 2-dimensional data set. But you are only taking 1 column ('d') from your data table. How does this become a 2-dimensional set of values with (row, column) indexes?