PHP - Count amount of rows joined
<p>I'm having the following code:</p>

<p>I wan't to count how many Answers there is to a specific Thread/lookup. Like, how many replied to this lookup.</p>

<pre><code>function lookup()
{
    $sql = "SELECT * FROM lookup
            INNER JOIN lookupCategories
            ON lookup.FK_lookupCategory=lookupCategories.lookupCategoriesId
            INNER JOIN lookupType
            ON lookup.FK_lookupType=lookupType.lookupTypeId
            LEFT JOIN authentication
            ON lookup.FK_lookupUserId=authentication.userId
            LEFT JOIN freelanceTypes
            ON lookup.FK_freelanceTypes=freelanceTypes.freelanceTypesId
            LEFT JOIN lookupAnswer
            ON lookup.lookupId=lookupAnswer.FK_lookupId
            ORDER BY lookupId DESC
            LIMIT 5";
    $result = mysql_query($sql)or die(mysql_error());

    $viewLookup = Array();

    while($row=mysql_fetch_assoc($result)):

        $viewLookup[$row['lookupId']]['lookupId'] = $row['lookupId'];
        $viewLookup[$row['lookupId']]['lookupHeader'] = $row['lookupHeader'];
        $viewLookup[$row['lookupId']]['lookupSubHeader'] = $row['lookupSubHeader'];
        $viewLookup[$row['lookupId']]['lookupContent'] = $row['lookupContent'];
        $viewLookup[$row['lookupId']]['lookupDate'] = $row['lookupDate'];
        $viewLookup[$row['lookupId']]['lookupCategory'] = $row['lookupCategoryName'];
        $viewLookup[$row['lookupId']]['lookupType'] = $row['lookupTypeName'];
        $viewLookup[$row['lookupId']]['lookupByUsername'] = $row['username'];
        $viewLookup[$row['lookupId']]['lookupByUserId'] = $row['userId'];
        $viewLookup[$row['lookupId']]['lookupFreelanceTypeId'] = $row['FK_freelanceTypes'];
        $viewLookup[$row['lookupId']]['freelanceWinner'] = $row['freelanceWinner'];

    endwhile;
    return $viewLookup;
}
</code></pre>

<p>And I wan't to count the amount of 'answers' to a thread. My threads are joined to the lookup's. And afterwards stored in an array as you see. </p>

<p>How would I count the answers, and store the number in the array together with the rest of my data? I have tried to do this, but can't figure out what's wrong. It's just returning if there's something or not - 1 or NULL. </p>

<pre><code>$viewLookup[$row['lookupId']]['countAnswers'] = count($row['lookupAnswerId']);
</code></pre>

<p>Thanks in advance :) </p>
