I have this program which I am trying to produce a a string for a jquery application that stores my data but can not get the string to produce right. This is the program:
if (!$db_selected) {
die();
echo "database not selected";
} else {
$query = "SELECT * FROM `events` WHERE `event_deletion` = 1";
$result = mysqli_query($conn, $query);
if (!$result) {
trigger_error("dbget: ".mysql_error()." in ".$query);
return false;
} else {
while ($row = mysqli_fetch_assoc($result)) {
$obj = array();
array_push($obj, $row['event_ID']);
array_push($obj, $row['event_name']);
array_push($obj, $row['event_start']);
array_push($obj, $row['event_end']);
array_push($xml, $obj);
//print_r($xml);
}
print(generateXML($xml));
}
}
function generateXML($array) {
$xmlString = "events: [";
for ($i = 0; $i < sizeof($array); $i++) {
$obj = $array[$i];
//print_r($obj);
$set = "{
id: \'" + $obj[0] + "\'," + print($obj[0] + "");
"title:\'" + $obj[1] + "\'," +
"start:\'" + $obj[2] + "\'," +
"end:\'" + $obj[3] + "\'";
//print($set + "\r\n");
$xmlString = $xmlString + $set;
}
return $xmlString = $xmlString + "]";
}
I need the string at the end to look like this format with the id, name, start, and end.
events: [{
title: 'All Day Event',
start: '2015-02-01'
}, {
title: 'Long Event',
start: '2015-02-07',
end: '2015-02-10'
}, {
id: 999,
title: 'Repeating Event',
start: '2015-02-09T16:00:00'
}, {
id: 999,
title: 'Repeating Event',
start: '2015-02-16T16:00:00'
},
]
I need the string to look like this above but I get this when I run the program:
connection made2345671044