I try to retrieve a array from one table What is wrong with this code?
$_fbexclude = mysql_query("SELECT fbempfang FROM fbinvite WHERE fbreturn = '1' ");
$fbexcludearray= mysql_fetch_array($_fbexclude);
// Convert the array
$excludes = implode(',', $fbexcludearray);
From echo $excludes; It only gives me just the following response: 1000033xxx161,1000033xxx161 Twice the same fbempfang
See if the following gives you what you want (FIXED):
mysql_fetch_array()and it’s siblings (_assoc,_row) only retrieve one row at a time. This means that your original code will only give you the first returned row – to work around this, we use the loop you see above.The reason you see the same data twice is because
mysql_fetch_array()returns a mixed indexed and associative array, which contains all the data twice over. For this reason, it is much better to usemysql_fetch_assoc()ormysql_fetch_row(), as you rarely need both formats.In fact, it is much better to use
mysqli, but the same information applies to that as well.