By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,191 Members | 1,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,191 IT Pros & Developers. It's quick & easy.

how to display/print images in 4x2 format.

100+
P: 254
Hi

I am facing problem while displaying the images dynamically on the webpage from database. Actually I am saving the path of the Image in database and it is displaying it from there .but it is displaying one image per row in table.

and I want to display two image per row in table.

for retriving data from data i am using ------ mysql_fetch_array() function.

so it is returning one image per page.

Please tell me how can I print two image per row in table from database like?

[IMG]image1[/IMG] [IMG]image2[/IMG]

[IMG]image3[/IMG] [IMG]image4[/IMG]

in this way.

please help me out.
Dec 14 '07 #1
Share this Question
Share on Google+
5 Replies


100+
P: 105
Your question is a bit ambigious.

If you HAVE both images and you cant display them in a row

TRY=> a css float option eg style="float:left"

OR

If you are having problem retrieving both the imges?

TRY=> store the images with a common id name + unique identifier,eg

image1 >> record1_1.jpg
image2 >> record1_2.jpg

then use a function such as glob() to extract the files eg
glob("record1_*")

regards
Dec 15 '07 #2

stepterr
100+
P: 157
I do something similar on a page of mine, but its 3 columns. This may not be the most efficient way, someone else may have a better solution for you, but it works perfectly for what I wanted.

[PHP]
$result = mysql_query("SELECT * FROM portfolio WHERE dcategory = 'Y' ORDER BY ppriority")or die(mysql_error());
$numcols = 0;
if ($result)
{
while ($array= mysql_fetch_assoc($result))
{
if ($numcols < 3)
{
?>
<td class='bodyText'><?php echo $array[category]?><br><img src='<?php echo $array[location]?>' style='cursor: pointer;' name='Thumbnails' border'0' onclick='OpenWindow("<?php echo $array[category]?>","<?php echo $array[projectname]?>")'/></td>
<?php
$numcols ++;
}
else
{
$numcols =0;
?>
<tr><td class='bodyText'><?php echo $array[category]?><br><img src='<?php echo $array[location]?>' style='cursor: pointer;' name='Thumbnails' border'0' onclick='OpenWindow("<?php echo $array[category]?>","<?php echo $array[projectname]?>")'/></td>
<?php
}
}
}
[/PHP]
Dec 15 '07 #3

100+
P: 254
Your question is a bit ambigious.

If you HAVE both images and you cant display them in a row

TRY=> a css float option eg style="float:left"

OR

If you are having problem retrieving both the imges?

TRY=> store the images with a common id name + unique identifier,eg

image1 >> record1_1.jpg
image2 >> record1_2.jpg

then use a function such as glob() to extract the files eg
glob("record1_*")

regards

Hi aktar

I am able to retrieve all the images but thing is that it is coming in a single column but I want it to come in two column dynamically.
Dec 15 '07 #4

Markus
Expert 5K+
P: 6,050
Hi there mukesh,

check out this thread i started a while ago. I had the same problem and pbmods gave me an excellent solution.

The solution - you might have to change a few little bits to adapt it. If you need some help just ask.

-markus
Dec 15 '07 #5

100+
P: 254
Hi there mukesh,

check out this thread i started a while ago. I had the same problem and pbmods gave me an excellent solution.

The solution - you might have to change a few little bits to adapt it. If you need some help just ask.

-markus
Hi Markusn

Need your help!. I am confused in the code so if you can please give me the code which is there at that link, because there is === and !==. and I am not sure that where will I put the code for dummy cell.

Please help me.
Dec 18 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.