Question : PHP array problem (filled with db data)

Hey people,

so I've got this
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
$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));	



But for some reason, it does not fill the array with the very first album.
So for example, nightwish has 6 albums in the database, the array only gets filled with the last 5, the first one in the database just isn't being put in it.

When Taylor Swift has only 1 album in the database, the array doesn't get filled at all.
Please help

(yes I know I can also use JOINs in my query, I will later on, just found this problem in an older script of mine and need it now)

Answer : PHP array problem (filled with db data)

The line "$albums = mysql_fetch_row($get_albums_sql);" fetches the first row already, you'll get all albums if you remove it.
Random Solutions  
 
programming4us programming4us