Jump to content

questions about how to display multiple pictures which are from database?


lukelee

Recommended Posts

here is my database looks like:

 

pid          title          thumb          imagedata

 

1            house            1              4352fdase234.jpg

2            farm              2              423fdsg43tghgh45.jpg

1            bed              1              hytuy56retgy4.jpg

1            hotel            1              554thser4fs.jpg

 

I want to display all the images which have thumb=1.

 

I can only make it display 1 image, here is my code. can anyone teach me how to display all thumb=1 images on a row? thanks

 

  <?PHP
require_once('db.php');
$query = mysql_query("SELECT * FROM image WHERE thumb = '1'");
$row = mysql_fetch_array($query);
?>
<ul>
<li><img src="upload/<?PHP echo $row['imagedata']; ?>" /></li>
<li></li>
</ul>

<?php
require_once('db.php');
$query = mysql_query("SELECT * FROM image WHERE thumb = '1'");
while($row = mysql_fetch_assoc($query)) {
?>
<ul>
<li><img src="upload/<?PHP echo $row['imagedata']; ?>" /></li>
<li></li>
</ul>
<?php } ?>

 

Something close to that?

<img height="xx" (or width="xx") src="[file]" />

 

Most modern browsers now will lock the ratio of the image to prevent distortion (if only one size restriction is placed,) if it's possibly going to be used in older browsers you may want to think about a script to create the height/width calculation or a script to create thumbnails.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.