Question: I need to add a counter to the loop as well as pulling contents. What is the syntax for adding the "and for ($ColCount = ColCount + 1)"

```
<?php $ColCount = 0?>
<!--get artwork thumbnails --> 
<?php
$dbname = 'pdartist2';
$table = 'artwork';
// query
$result = mysql_query("SELECT AID, ThumbFilePath, Title, DisplayOrder FROM artwork where SCID = '$SCID' ") or die(mysql_error());
while($row = mysql_fetch_row($result))
{
    foreach($row as $cell)
    and for ($ColCount = ColCount + 1) 

echo "$ColCount", "$cell";
}
mysql_free_result($result);
?>

```

Answer: 
I have no idea if that's valid in PHP. Maybe all it is is a forgotten `$` sign before `ColCount`. But you could just do it the normal way:

```
foreach($row as $cell) {
    $ColCount++;

    echo $ColCount . $cell;
}

$ColCount = 0;

```
What i'll do is use an array like that

```
    <!--get artwork thumbnails --> 
    <?php
    $dbname = 'pdartist2';
    $table = 'artwork';

    # Define array
    $Count = array();

    // query
    $result = mysql_query('SELECT AID, ThumbFilePath, Title, DisplayOrder FROM artwork where SCID = '.$SCID) or die(mysql_error());
    while($row = mysql_fetch_row($result)){
        foreach($row as $cell){
            $Count[$Cell]['Count'] = $Count[$Cell]['Count']++;
        }

        echo $ColCount.', '.$cell;
    }
    mysql_free_result($result);

```

So you have the count for each colomn but what I suggest is to use the mysql\_num\_rows(); like that :

$Query = mysql\_query...
$Count = mysql\_num\_rows($Query);

$Count will be a number ;)

Then if($Count > 0)