I have PHP file on server. It queries database and needs to return multiple rows. In my PHP file I store the query result into an array using:
Some inline
I need to return this array to my javascript file using echo (as it seems to be only way that works) I am using: echo json_encode($push); at the moment. only problem is that this returns it was a string.
I need to use it on my javascript side as an array as I loop through the 2-D array and display it onto my table. I have been just testing the looping through the 2-D array using hardcoded array I created on my javascript side.
My question is and I am not sure if this is a stupid question that I should already know but I have tried everything I could think of. Is there a better way to return the array as an actual array so I can loop through it in my javascript file using:
Some inline
Some inline
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
$push[] = $row;
}
I need to return this array to my javascript file using echo (as it seems to be only way that works) I am using: echo json_encode($push); at the moment. only problem is that this returns it was a string.
I need to use it on my javascript side as an array as I loop through the 2-D array and display it onto my table. I have been just testing the looping through the 2-D array using hardcoded array I created on my javascript side.
My question is and I am not sure if this is a stupid question that I should already know but I have tried everything I could think of. Is there a better way to return the array as an actual array so I can loop through it in my javascript file using:
Some inline
var result = "<table border=0,width=1000px>";
result += "<thead><tr><th>Speciality</th><th>Job Title</th><th>Location</th><th>View</th></thead><tbody>";
for (var i = 0; i < array.length; i++)
{
result += "<tr>";
for (var j = 0; j < array[i].length; j++)
{
if(j < 3)
{
result += "<td>" + array[i][j] + "</td>";
}
else
{
result += "<td>" + array[i][j] + "</td>";
}
}
result += "<td align=center><button>Click</button></td>";
result += "</tr>";
}
result += "</tbody></table>";
document.getElementById("container").innerHTML = result;



