PHP
$table = $_REQUEST['table'];
$query = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = $table";
$result = mysql_query($query);
$i = 0;
$arr = array();
while($row = mysql_fetch_array($result, MYSQL_NUM)) {
$arr[$i] = $row['COLUMN_NAME'];
$i++;
}
echo json_encode($arr);
Javascript
$("#verticalSelect").change(function() {
var table = $("#verticalSelect option:selected").attr('value');
$.post(PROCESSORFILE, {"task": "getTableDupeFields", "table": table}, function(data) {
alert(data);
}, "json");
});
I want take the array $arr
from php and pass it to javascript where I can print its contents one by one. So far the code I have and variations of have returned errors, resource Id's and often just nothing at all.
How can this be done in the most trite way?