Php 将团队名称替换为表中的徽标
我有一个脚本,可以从MySQL中提取数据并将其安排在一个表中,但我希望将标记中的Team 1、Team 2和Organizer输出替换为存储在web服务器上的图像,但我不知道如何执行此操作 我的脚本:Php 将团队名称替换为表中的徽标,php,html,css,mysql,Php,Html,Css,Mysql,我有一个脚本,可以从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
<?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);
?>
一种方法是在文件名中使用团队的唯一id(例如
/team img/1.jpg
),然后使用php和mysql获得:
.jpg>
您是否在任何地方定义了团队名称到徽标的映射?目前还没有,我无法100%确定如何执行此操作。然后您需要在某个位置(可能是数据库)定义/存储团队和徽标URL之间的映射。然后您可以从数据库中读取相应列并显示徽标。