s4salman Posted June 5, 2018 Share Posted June 5, 2018 (edited) 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); ?> Edited June 5, 2018 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/307347-image-print-help-in-php/ 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' >" Quote Link to comment https://forums.phpfreaks.com/topic/307347-image-print-help-in-php/#findComment-1558770 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. ? Quote Link to comment https://forums.phpfreaks.com/topic/307347-image-print-help-in-php/#findComment-1558771 Share on other sites More sharing options...
Barand Posted June 5, 2018 Share Posted June 5, 2018 Done. 1 Quote Link to comment https://forums.phpfreaks.com/topic/307347-image-print-help-in-php/#findComment-1558772 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.