Question: I have the following loop:

```
    while($row = mysql_fetch_assoc($result)) {
    <some code>
     if ($user)
                echo '<li><a href="mahjong.php?layout='.$row['LayoutName'].'"><img src="images/layouts/'. $row['LayoutName'].'.png" alt="" /> <img src="images/'. $row['Stars'].'.png" alt="" /></a>
                        <div class="info">
                            <h2>'.$row['LayoutName'].'</h2>
                            <p>'.$row['LayoutTiles'].' Tiles, '.$row['LayoutLayers'].' Layers</p>
                            <hr size=2 color="white"> 
                            <p>Score: '.$row['Score'].'</p> 
                            <p>Time:&nbsp;&nbsp;'.$row['Time'].'</p>
                        </div>
                      </li>';
            else 
    <some more code> 
}

```

This while loop works perfectly, but sometimes some variables have no data. This is correct, because there is simple none in the database. If this happens, it shows nothing. I want it so, that if the variable is empty, it echoes a 0.

Example `$row['Score']` = empty -> 0

Thanks,

ps it is possible that `$row['Time']` has a value and `$row['Score']` not!!

Answer: 
In recent PHP versions you can use `$row['Score'] ?: 0` etc.
If you want to leave the code as it is you could use the sql method coalesce:

```
select coalesce(score, 0) as score from table

```

coalesce returns the first non-null parameter.