S
S
svilkov872015-11-24 21:25:29
PHP
svilkov87, 2015-11-24 21:25:29

Image not showing up when fetching from database?

Hi all!
I extract information from the database. Everything is displayed, except for pictures (they are default)
Please look at the code:

$result = mysql_query("SELECT * FROM news ",$link);
$row = mysql_fetch_array($result);

do{
    echo '
    <h2>'.$row["title"].'</h2>
    <img src="/images/'.$row["image"].'"/>
    <p>'.$row["text"].'</p>
        
    ';
}
while($row = mysql_fetch_array($result));

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
IceJOKER, 2015-11-24
@IceJOKER

Couldn't this be written more concisely?

$result = mysql_query("SELECT * FROM news ",$link);

while($row = mysql_fetch_array($result)){

    echo '
    <h2>'.$row["title"].'</h2>
    <img src="/images/'.$row["image"].'"/>
    <p>'.$row["text"].'</p>
        
    ';

  var_dump($row['image']); //посмотрите что внутри
}

M
Miku Hatsune, 2015-11-24
@Hatsune-Miku

Do you store the path to the image or directly the image itself in the database?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question