Solved

image display php

Posted on 2016-07-16
9
59 Views
Last Modified: 2016-07-16
<?php
$link2 = "http://localhost:888/dropzone/uploads";
$image = "/uploads";

$sql = "SELECT id, file_name FROM files";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["file_name"] . "- Image: ". <img src= "<?php echo $image.$row['file_name']; ?>"> . "<br>";

    }
} else {
    echo "0 results";
}
$conn->close();

?>

Open in new window


The above code works if I do not include this line (I get the correct list of data):
<img src= "<?php echo $image.$row['file_name']; ?>">

I need the image to be displayed
0
Comment
Question by:doctorbill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 9

Assisted Solution

by:Moussa Mokhtari
Moussa Mokhtari earned 500 total points
ID: 41714547
@doctorbill
its just a syntax error
change you echo line to be like this
 echo "id: " . $row["id"]. " - Name: " . $row["file_name"] . "- Image: ". "<img src=".'"$image.$row['file_name']"'."><br>";

Open in new window

0
 

Author Comment

by:doctorbill
ID: 41714569
Sorry - still not working
0
 

Author Comment

by:doctorbill
ID: 41714587
<?php
$link2 = "http://localhost:888/dropzone/uploads";
$image = "uploads/";

$sql = "SELECT id, file_name FROM files";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["file_name"] . "- Image: ". "<img src=".$row["file_name"]." /> " . "<br>";

    }
} else {
    echo "0 results";
}
$conn->close();

?>

Open in new window


The above code does not give a page error but still only shows an image placeholder
This is the url from the image placeholder:
http://localhost:888/development/dev/html5/DropZone/test4.txt

I need to append the following to the image name:
uploads/
So the url will be:
http://localhost:888/development/dev/html5/DropZone/uploads/test4.txt
0
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 

Author Comment

by:doctorbill
ID: 41714590
This is now working:

<?php
$link2 = "http://localhost:888/dropzone/uploads";
$image = "uploads/";

$sql = "SELECT id, file_name FROM files";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["file_name"] . "- Image: ". "<img src=".$image.$row["file_name"]." /> " . "<br>";

    }
} else {
    echo "0 results";
}
$conn->close();

?>

Open in new window

0
 

Author Comment

by:doctorbill
ID: 41714599
Now this is working, how do I dictate an image width
0
 
LVL 9

Accepted Solution

by:
Moussa Mokhtari earned 500 total points
ID: 41714607
Hard code them

<?php
$link2 = "http://localhost:888/dropzone/uploads";
$image = "uploads/";

$sql = "SELECT id, file_name FROM files";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["file_name"] . "- Image: ". "<img src=".$image.$row["file_name"]." width='200px' height='200px'/> " . "<br>";

    }
} else {
    echo "0 results";
}
$conn->close();

?>

Open in new window

1
 

Author Comment

by:doctorbill
ID: 41714609
Awesome - thanks
0
 
LVL 9

Expert Comment

by:Moussa Mokhtari
ID: 41714610
You're welcome :)
0
 

Author Closing Comment

by:doctorbill
ID: 41714614
Completed
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question