I'm probably going in the complete wrong direction but I want to get an array of data from the database and then use that array in another SQL statement.
Here is my current code:
$result = mysql_query($query_friend_club_count) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$row['idPerson']. " - ". $row['idFriend'];
$idFriend = $row['idFriend'];
$array = $idFriend',';
$query_friends = "SELECT * FROM whosout WHERE idPerson IN ('$array')";
$query_friends_run = mysql_query($query_friends);
$friendCounter = mysql_num_rows($query_friends_run);
echo $friendCounter;
}
I'm getting a error of:
syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Don't know if that helps.
Any suggestions would be really helpful as I've been stuck on this for ages!!
whileloop?$query_friend_club_countis?mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi. This article will help you decide which.$array = $idFriend',';? Change to$array = $idFriend.',';