I am trying to populate dropdown-list with new data by calling a PHP page which returns an array of values.
Here is my PHP page:
<?php
if(isset($_GET['catid']))
{
$conn = mysql_connect("localhost","krupa4e_skyways","skyways@1347","krupa4e_skyways");
if (!$conn)
{
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!mysql_select_db("krupa4e_skyways"))
{
echo "Unable to select mydbname: " . mysql_error();
exit;
}
$cat=$_GET['catid'];
$getsubcategoriesssql='select scid,sc_name from subcategories where catid='.$cat;
$result=mysql_Query($getsubcategoriesssql,$conn);
if (!$result)
{
die('Invalid query: ' . mysql_error());
}
$output=array();
while($row=mysql_fetch_row($result))
{
array_push($output,$row[0],$row[1]);
}
echo $output;
}
?>
How can I obtain the data I need using jQuery and bind that to an array, and later to a dropdown-list?