Answer the question
In order to leave comments, you need to log in
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
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']); //посмотрите что внутри
}
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 questionAsk a Question
731 491 924 answers to any question