我正在将值插入sql表并通过AJAX显示它。值会正确显示,但图像不在右列,而是在顶部。为什么会这样?
<?php
...
...
...
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
$output .= '
<div class="table-responsive">
<table class="table table bordered">
<tr>
<th>ID</th>
<th>Name</th>
<th>Time</th>
<th>Img</th>
</tr>
';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["ID"].'</td>
<td>'.$row["Name"].'</td>
<td>'.$row["Time"].'</td>
<td>' ?> <img src="<?php echo $row['Img']; ?>" alt="my picture" height="100" width="100" /> <?php '</td> //Here is the problem where I am trying to display the image
</tr>
';
}
echo $output;
}
else
{
echo 'Data Not Found';
}
?>
答案 0 :(得分:1)
if(mysqli_num_rows($result) > 0)
{
$output .= '
<div class="table-responsive">
<table class="table table bordered">
<tr>
<th>ID</th>
<th>Name</th>
<th>Time</th>
<th>Img</th>
</tr>
';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["ID"].'</td>
<td>'.$row["Name"].'</td>
<td>'.$row["Time"].'</td>
<td> <img src="' .$row["Img"] . '" alt="my picture" height="100" width="100" /> </td> //Here is the problem where I am trying to display the image
</tr>';
}
$output .= '</table></div>';
echo $output;
}
else
{
echo 'Data Not Found';
}
尝试这种方式。