John Davidson

php - I have an svg image and I want the link of the image to be looped but it only displays one image

0 comments
Message:


THIS IS MY CODE BELOW


<?php $stmt = $dbh->prepare("SELECT * FROM `cms_team`");
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
$link = str_replace("../", "https://example.com/", $row["team_photo"]);
if($row["team_order"]>0)
{

echo ' <div class="col-md-4 text-center">

<svg viewbox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="img" patternUnits="userSpaceOnUse" width="140" height="140">
<image xlink:href="'.str_replace("../", "https://example.com/", $row["team_photo"]).'" x="-25" width="170" height="120" />
</pattern>
</defs>
<polygon id="hex" points="50 1 95 25 95 75 50 99 5 75 5 25" fill="url(#img)"/>
</svg><br>
<h2 style="color:#`ffffff`"><?=$row["team_name"];?></h2>
<p style="color:#fff" class="mt-2"><?=$row["team_short_bio"];?></p>
<p><a class="btn btn-success" href="#" style="color:#fff">View details</a></p>


</div><!-- /.col-lg-4 -->';

}
}
?>

I NEED to create multiple svgs but it only gets the first image and creates its svg thus it replicates the same image over and over again



My Answer:
// Define the number of times to loop the image
$loopCount = 5;

// Loop through the images
for ($i = 0; $i < $loopCount; $i++) {
echo 'Image';
}
?>

Rate this post

3 of 5 based on 2952 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us