[PHP] Outputting specific HTML for table tag.

2001-01-22 Thread James, Yz

Hey all.  well, here's (probably) an easy question from me again (surprise
surprise).

Here goes:  I'm putting together a photo gallery for some friends of mine
who own a nightclub, and who want to update photos themselves. I know
there are scripts available to do the job, but I'd like to have a go at my
own.

Most of the stuff I can handle, but I just need to know what code I might
use for returning table cells correctly.  Let's say, for example, there are
5 photos that need returning to one of the photo pages, and I have the
photos in rows of three;  Obviously, there'd be an empty table cell.  And
I'm not sure exactly how I get the results back into rows correctly
anyway...  Bullet points and whole table rows are fine, but table cells?
Hrms.

Anyway, here's how I might've started writing the code, if I hadn't realised
I should ask for help first ;) :

?

//  Connection code

$table = "table border=\"0\" /* Yadda Yadda */ ";

while($row = mysql_fetch_array($result)) {

$row = $photo['photo'];

$table .= "trtd$photo/td"
$table .= "td$photo/td/tr";

}

$table .= "/table";

//  End Crap programming.

?

So.  Any takers?  :)

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Outputting specific HTML for table tag.

2001-01-22 Thread Richard Lynch

 5 photos that need returning to one of the photo pages, and I have the
 photos in rows of three;  Obviously, there'd be an empty table cell.  And

 ?

 //  Connection code

 $table = "table border=\"0\" /* Yadda Yadda */ ";


$table .= "tr";
$photocount = 0;

 while($row = mysql_fetch_array($result)) {

 $row = $photo['photo'];

# $table .= "trtd$photo/td"
# $table .= "td$photo/td/tr";

$table .= "td$photo/td";
$photocount++;

if (($photocount % 3) == 2){
#time to start a new row:
$table .= "/trtr";
}


 }

$table .= "/tr";

 $table .= "/table";

 //  End Crap programming.

 ?

The % operator is the "modulo" operator, aka "clock arithmetic".

Using $x % 3 makes it "count by threesies" and "wrap-around" to 0 when you
pass 2...

Anyway, when you hit '2', it will dump out the end row and new row tags.

BTW:  Any particular reason for building up the $table variable instead of
just spewing it out to the browser with echo (or print)?...  Unless you are
building some kind of template system, you are just making life hard on
yourself with it...

Don't miss the Zend Web Store's Grand Opening on January 23, 2001!
http://www.zend.com
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]