I have a script that pulls data form MySQL and arranges it in a table but I want the Team 1, Team 2, and Organizer outputs within my tags to be replaced with an image stored on my web server but I have no clue how to do this
My Script:
<?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);
?>
One way to do this is by using the team's unique id in the filename (eg /team-img/1.jpg
), and then using php and mysql to get that:
<img src="/team-img/<?php echo $id; ?>.jpg">