0

I am trying to display an image. I have fetched my URL from the db storage. And i have used the php variable inside the image tag. But the code does'nt display any image .

what is the problem? exactly!

this is my code below

  <?php $db =& JFactory::getDBO();

            $query88=$sql = "SELECT file_url_thumb FROM fs01_virtuemart_medias WHERE virtuemart_media_id=1 LIMIT 0, 30 ";

            $result88 = mysql_query($query88) or die(mysql_error());

      ?><img src="<?php while($row = mysql_fetch_array($result88)){
            echo $row['file_url_thumb'];
            echo "<br />";
            } ?>" border="0" style="border: 0; vertical-align: top;" />

3 Answers 3

1

You are looping over your results and putting them all (each followed by a <br /> inside the src attribute of an img tag. It seems highly unlikely that that won't 404.

You probably want something more like:

<ul>
  <?php while($row = mysql_fetch_array($result88)){ ?>
    <li><img src="<?php echo htmlspecialchars($row['file_url_thumb']); ?>" /></li>
  <?php } ?>
</ul>          

(With some CSS from an external stylesheet to apply your presentation).

Sign up to request clarification or add additional context in comments.

Comments

0
<?php

$db = &JFactory::getDBO();

$query88 = "SELECT file_url_thumb FROM fs01_virtuemart_medias WHERE virtuemart_media_id=1 LIMIT 0, 30 ";

$result88 = mysql_query( $query88 ) or die( mysql_error() );

while( $row = mysql_fetch_array( $result88 ) ) {
    echo '<img src="' . $row[ 'file_url_thumb' ] . '" border="0" style="border: 0; vertical-align: top;" /><br />';
}

?>

Comments

0

use this

 <?php
$db = &JFactory::getDBO();

$query88 = "SELECT file_url_thumb FROM fs01_virtuemart_medias WHERE virtuemart_media_id=1 LIMIT 0, 30 ";

$result88 = mysql_query( $query88 ) or die( mysql_error() );

    while($row = mysql_fetch_array($result88)){ 
                echo '<img src="'.$row['file_url_thumb'].'" style=" border="0" style="border: 0; vertical-align: top;"/>';
                echo '</br>';
                }
                ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.