Solved

image display php

Posted on 2016-07-16
9
43 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
  • 6
  • 3
9 Comments
 
LVL 9

Assisted Solution

by:Moussa Mokhtari
Moussa Mokhtari earned 500 total points
Comment Utility
@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
Comment Utility
Sorry - still not working
0
 

Author Comment

by:doctorbill
Comment Utility
<?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
 

Author Comment

by:doctorbill
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

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

Accepted Solution

by:
Moussa Mokhtari earned 500 total points
Comment Utility
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
Comment Utility
Awesome - thanks
0
 
LVL 9

Expert Comment

by:Moussa Mokhtari
Comment Utility
You're welcome :)
0
 

Author Closing Comment

by:doctorbill
Comment Utility
Completed
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now