Hi I'm trying to make an array " events" in javascript that is filled with objects of two properties {Title: , Date:}
But, the value of those two properties is brought from the database using PHP!
Here's my code but I don't know why it doesn't work..
var events = [
<?php
//Connect to mysql server
//Select database
$result=mysql_query("SELECT * FROM event");
$count = mysql_num_rows($result);
if($count>0){
for($i=0;$i<$count-1;$i++){
$row= mysql_fetch_row($result);
echo "{ Title: ".$row['title'].", Date: ".$row['date']." },";
}
$row= mysql_fetch_row($result);
echo "{ Title: ".$row['title'].", Date: ".$row['date']." }";
}
?>];
json_encode()would make this much easier.