s4salman Posted June 5, 2018 Share Posted June 5, 2018 I want to print image in the following Php code along with the name of the image. I want to print name in first row of the html table, while full image in the 2nd row. row[5] contain image file name such as abc.jpg. I want to print whole image url like this in second row: https://xyz.com/po/row[5] Can any body help me how i can do this. I tried different code but could not succeed. <?php $con=mysqli_connect("localhost","****","****","s4salman_color"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $url = $_GET['url']; $sql="SELECT * FROM coloringpages where url = '$url' ORDER BY id"; if ($result=mysqli_query($con,$sql)) { // Fetch one and one row while ($row=mysqli_fetch_row($result)) { printf ("%s (%s)\n",$row[0],$row[5]); } // Free result set mysqli_free_result($result); } mysqli_close($con); ?> Link to comment Share on other sites More sharing options...
Barand Posted June 5, 2018 Share Posted June 5, 2018 To display an image you need to use an html <img> tag EG echo "<img src='path/to/image' >" Link to comment Share on other sites More sharing options...
dalecosp Posted June 5, 2018 Share Posted June 5, 2018 It might also be wise to redact (that is, remove or obfuscate/cover-up) your DB credentials in your example code's mysqli_connect() function. ? Link to comment Share on other sites More sharing options...
Barand Posted June 5, 2018 Share Posted June 5, 2018 Done. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.