Re: How to arrange image

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You essentially have 3 problems.
1. HTML formatting. Just dropping in a <p> tag without closing tags  
isn't up to standards. You also need quotes around your attributes  
for the image tag. *And* your image tag isn't closed. So, right now  
your formatting is like this:
<img src=img-name-here.jpg height=150 width=150>
<p>
<img src=img-name-here.jpg height=150 width=150>
<p>
<img src=img-name-here.jpg height=150 width=150>
<p>

etc, etc, etc.

This is what it *needs* to look like:
<p><img src="img-name-here.jpg" height="150" width="150" /></p>
<p><img src="img-name-here.jpg" height="150" width="150" /></p>
<p><img src="img-name-here.jpg" height="150" width="150" /></p>

2. You need to left align all of the first items you want in the row.  
So your new code would look like this:
<p style="float:left;"><img src="img-name-here.jpg" height="150"  
width="150" /></p>
<p style="float:left;"><img src="img-name-here.jpg" height="150"  
width="150" /></p>
<p><img src="img-name-here.jpg" height="150" width="150" /></p>

3. You need an additional check inside your while to make sure the  
<p> tag is supposed to be floated. Something like this would work:
$i = 1;
while($row=mysql_fetch_array($sql)) {
	$imgsrc = $row[pictures];
	$floated = '';
	if (($i % 3) == 0) { $floated = ' style="float:left;"'; }
	echo'<p'.$floated.'><img src="'.$imgsrc.'" height="150" width="150" / 
 ></p>';
	$i++;
}

All of this adds up to a couple of things:
1. You NEED to go back and learn HTML and CSS.
2. Study loop logic.
--
Joe

On Dec 31, 2009, at 3:08 AM, Gab Teo wrote:

>
> Below is the script that echo out the photos,
>
> <?php
>
>
>
> include ("connect.php");// my database connect file
>
> $sql=mysql_query("select pictures from album where  
> username='$username'");
>
> while($row=mysql_fetch_array($sql))
>
> {
>
> $imgsrc=$row[pictures];
>
> echo "<img src=$imgsrc height=150 width=150>";
>
> echo "<p>";
>
> }
>
> ?>
>
> I am currently having photos outputting  in this form
>
> 1
>
> 2
>
> 3
>
> 4
>
> e.t.c
>
> and I want it in this form
>
> 1 2 3
>
> 4 5 6
>
> 7 8 9
>
> e.t.c
>
> or
>
> 1 2
>
> 3 4
>
> 5 6
>
> e.t.c
>
> Thanks,
>
> Gab
>

>
> From: php-objects@ yahoogroups. com [mailto:php-objects@  
> yahoogroups. com] On
>
> Behalf Of Joe Forsythe
>
> Sent: Wednesday, December 30, 2009 9:06 AM
>
> To: php-objects@ yahoogroups. com
>
> Subject: Re:  How to arrange image
>
> What is the code you're using right now so we can help you debug it?
>
> --
>
> Joe
>
>

> On Dec 30, 2009, at 3:49 AM, Gab Teo wrote:
>
> > Please can someone help, I just created a proile for users where
>
> > they can also upload their photo album, this is coming (outputing)
>
> > in one column and rows, and I want it to be in three column rows,
>
> > so that they can have their photos in three per column and as they
>
> > upload more photos it would be that this three column s maintain
>
> > down the rows. Can any one help me please.
>
> > Gab
>



[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux