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: 
As Bruce said, you could just do $ColCount++, But also you could just count the results with mysql\_num\_rows

```php
$result = mysql_query("SELECT AID, ThumbFilePath, Title, DisplayOrder FROM artwork where SCID = '$SCID' ") or die(mysql_error());
$numRows = mysql_num_rows($result);

```

Shai
You are missing a semi-colon:

```
<?php $ColCount = 0?>

```

Should be:

```
<?php $ColCount = 0; ?>

```

And:

```
while($row = mysql_fetch_row($result)) {
    foreach($row as $cell) {
        $ColCount++; // adds 1 to colcount

        echo $ColCount.$cell; // no need for quotes around variables. Also string concatination in PHP is using s dot (.)
    }
 }

mysql_free_result($result);

```