I retrieve data from my database as such:
while($row = mysql_fetch_array($result))
{
echo $row['uid'];
echo $row['note'];
}
and I print it with ajax as such:
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
console.log(xmlhttp.responseText)
}
}
but the problem is that the uid and note its one string. For example:
"45 note goes here"
How can I print each row separately. Something like this:
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
console.log( <?php echo json_encode($row['uid']); ?> );
console.log( <?php echo json_encode($row['note']); ?> );
}
}
mysql_fetch_array
into one array and out it in oneecho
as json withjson_encode
.