我有一个脚本从MySQL中提取数据并将其排列在一个表格中,但我希望我的标签中的Team 1,Team 2和Organizer输出被存储在我的Web服务器上的图像替换但我不知道怎么做
我的剧本:
<?php
$con=mysqli_connect("localhost","username","password","dbname");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM ECmatches");
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Team 1</th>
<th>Score</th>
<th>Team 2</th>
<th>Best Of</th>
<th>Maps</th>
<th>Organizer</th>
<th>Match Time</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['MatchID'] . "</td>";
echo "<td>" . $row['Team1'] . "</td>";
echo "<td>" . $row['Score'] . "</td>";
echo "<td>" . $row['Team2'] . "</td>";
echo "<td>" . $row['Series'] . "</td>";
echo "<td>" . $row['Maps'] . "</td>";
echo "<td>" . $row['Organizer'] . "</td>";
echo "<td>" . $row['MatchTime'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
答案 0 :(得分:0)
这样做的一种方法是在文件名中使用团队的唯一ID(例如/team-img/1.jpg
),然后使用php和mysql来获取:
<img src="/team-img/<?php echo $id; ?>.jpg">