如何检查数据库中的表格单元格并输出结果?

I am bit new to php and sql.

I am simply reading from a database table and echoing images to a page. The images are then styled with a text aligned in the middle saying 'Play Video'.

In the table 'adcTable' some entries do not have a video stored. I would like to have the rows/entries with video say 'Play Video' and the ones without just show the image.

Not to sure how bess to explain. Hope to get some assistance.

<php
$sql = "SELECT client_id, images, video FROM adcTable";
$result = $conn->query($sql);

$count = 1;

echo "<table  border = '0' width='720'><tr>";

while($row = $result->fetch_assoc()) {
echo "<td><div class='ccontainer'>"; ?><img class="cimage" src= "<?php echo  $row ["images"];?> " ><?php echo "

<div class='middle'> 
<div class='text'>Play Video</div>
</div>
</div>
</td>";


if ($count++ % 2 == 0) {
echo "</tr><tr>";
} 

echo "</tr></table>";

?>

Use if empty condition on video column. This is the fundamental code, add your formatting as required.

 <?php

        while($row = $result->fetch_assoc()) {

          if (empty ($row['video']) ) {

            echo  $row ["images"];

          } else {

            echo "Play Video";

          }

        }

 ?>

SO reference to related post

Thanks guys, I was able to use the example provided by BusinessPlanQuickBuilder to solve.

$sql = "SELECT client_id, files, file FROM adcTable";
$result = $conn->query($sql);

$count = 1;


echo "<table  border = '0' width='720'><tr>";

while($row = $result->fetch_assoc()) {

if ($row['file'] == "VidUploads/"){ 

echo "<td>"; ?><img class="cimage" src= "<?php echo $row ["files"];?> " ><?php echo "

</td>";
echo '<script type="text/javascript">',
     '$( ".text" ).css( "border", "3px solid red" );',
     '</script>'; 
} else{

echo "<td><div class='ccontainer'>"; ?><img class="cimage" src= "<?php echo $row ["files"];?> " ><?php echo "

<div class='middle'> 
<div class='text'>Video</div>
</div>
</div>
</td>";
}

if ($count++ % 2 == 0) {
echo "</tr><tr>";
} 
} 
echo "</tr></table>";

?>