$artistname = trim($_POST['artistname']);
$get_artistID_sql = mysql_query("SELECT artistID FROM artists WHERE artistname = '".mysql_real_escape_string($artistname)."'");
$artistID = mysql_fetch_row($get_artistID_sql);
$get_albums_sql = mysql_query("SELECT albumname FROM albums WHERE artistID = '".$artistID[0]."'");
$albums = mysql_fetch_row($get_albums_sql);
$j = array();
while ($row = mysql_fetch_array($get_albums_sql))
{
$j[] = array(value=>$row[0],name=>$row[0]);
}
echo json_encode(array("results"=>$j));
|