1

I'm using google Line chart for my college project, here i want to add rows dynamically based on the user selection from database, addRow() function is used to add a row but i want it to be add by looping. someone can help me?

Here is my code:

var rowArray1 = [];
var rowArray2 = [];
<?php
for($i=1;$i<=$count;$i++)
{
$row=mysql_fetch_array($rows);
echo "rowArray1.push('". $row['a'] ."')";
echo "rowArray2.push(". $row['b'].")";

array_push($rowArray,"'".$row['a']."',".$row['b']);
} 
?>


for(i=0;i<count;i++)
{
   data.addRow( [rowArray1[i], rowArray2[i]] );
}

it's not working properly... :-(

1 Answer 1

1

Finally I got the solution. it's very simple way. when i asked this question, i was just a beginner so i dont know how to do it. now i got the answer.

I just included the PHP scripts inside the javascript code like this,

<script>
// Google chart codes....

<?php
  $row=mysql_fetch_array($rows);
  foreach($row as $data) {
    echo "data.addRow( $data['a'] , $data['b'] );";  
  } 
?>

// Google chart codes....
</script>

It's worked fine... :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.