试试这个
<?
// Check connection
if (!$conn) {
die("Connection failed:");
} else {
// Proceed with your database operations here
$cmd = "SELECT a.caption, b.img_loc
FROM captions a
INNER JOIN images b ON a.caption_id b.caption_id
WHERE a.caption_id = b.caption_id " ;
// Added space after "images"
$result = mysqli_query($conn, $cmd);
// Fetch data and store in arrays
?>
<h2>Captions Table</h2>
<table>
<thead>
<tr>
<th>Number</th>
<th>Caption</th>
</tr>
</thead>
<tbody>
<? $num=0;
while ($row = mysqli_fetch_assoc($result)) {
?>
<tr>
<th><?=$num?></th>
<th><?=$row['caption']?></th>
</tr>
<? $num ++ ;
} ?>
</tbody>
</table>