I have a MySQL table with cols | btn_id | btn_title | btn_bg | btn_text |.
I am trying to get the data in the table to a php array and then return via JSON so the array can be used in the JS document requesting the PHP/MySQL Data. Respective of row and columns/index.
So far i have:
$sql = 'SELECT *
FROM btn_color_presets
';
$result = mysqli_query($sql);
$array = array(); //
while($row = mysql_fetch_assoc($result)) //
{
$array[] = $row;
$index++;
}
Q. Now i wish to return a JSON Array made from the array of data. How do i proceed here?
Note: I am horrible with arrays and not entirely sure i have the correct method above for my requirements, but i think it is correct.
$index, just use$array[] = $rowto add a new element to an array.