Solved

image display php

Posted on 2016-07-16
9
51 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
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
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 dynamically set the form action using jQuery.

810 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