Re: [PHP] Create a matrix gallery
> What I want to to do is insert a new after showing 5 thumb images, and > continue with the next picture on the next row. > something like this > __ > |pic1 | pic2 | pic3 | pic4 | pic5 | > __ > |pic6 | pic7 | pic8 | pic9 | pic10 | > __ > |pic11 | pic12 | pic13 | > __ You need to use the math function: modulo. $MaxRows = 5; for(...){ $m = fmod($ImageNumber, $MaxRows); if($m == 0){ echo ""; } echo ""; // [...] content of cell here echo ""; if($m == ($MaxRows-1)){ echo ""; } } Have fun! Simon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Create a matrix gallery
> -Mensaje original- > De: Stut [mailto:[EMAIL PROTECTED] > Enviado el: Lunes, 03 de Septiembre de 2007 06:31 p.m. > Para: Humani Power > CC: php-general@lists.php.net > Asunto: Re: [PHP] Create a matrix gallery > > Humani Power wrote: > > hi list. I wonder if anyone can help me with this. > > i have a database with the file name of several images stored in a > > filesystem, and I want to create a table containing the image results of > a > > query. > > > > this is my code > > > > > while ($rows=mysql_fetch_assoc($getpic)) > > { > > extract ($rows); > > echo ""; > > echo " > src=".$ImageThumb.$rows['image_id'].".jpg>"; > >} > > > With this code, I am able to see the thumb images with their respective > link > > ok, but if I have a query with 40 results, I will have a big row of > images. > > > > > > |pic1 | pic2 | pic3 | pic4 | pic5 | pic6 | pic7 | pic8 | pic9 | pic10 | > > __ > > > > > > What I want to to do is insert a new after showing 5 thumb images, > and > > continue with the next picture on the next row. > > something like this > > __ > > |pic1 | pic2 | pic3 | pic4 | pic5 | > > __ > > |pic6 | pic7 | pic8 | pic9 | pic10 | > > __ > > |pic11 | pic12 | pic13 | > > __ > > This is really quite simple... > > $col = 1; > while ($rows=mysql_fetch_assoc($getpic)) > { > extract ($rows); > if ($col == 1) echo ""; > echo " src=".$ImageThumb.$rows['image_id'].".jpg>"; > if ($col++ == 5) > { > echo ""; > $col = 1; > } > } > > Not sure why you are using extract when you then go on to use $rows as > an array. Also, you're lacking quotes around the href in the link you > output, and also the src in the image. It's also missing a closing > tag. And you should be using urlencode when putting values into a URL. > And while I'm at it, $row is more semantically correct than $rows. > > Try this... > > $col = 1; > while ($row = mysql_fetch_assoc($getpic)) > { > if ($col == 1) echo ''; > $image_id = urlencode($row['image_id']); > echo ' href="editing_image.php?pic='.urlencode($image_id).'"> src="'.$ImageThumb.urlencode($image_id).'.jpg" />'; > if ($col++ == 5) > { > echo ''; > $col = 1; > } > } > > -Stut > > -- > http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Create a matrix gallery
Hotmail sucks but try this [code] $counter = 1; while ($rows=mysql_fetch_assoc($getpic)) { //close the tr tag after 5 photos usng the mod function to check the counter if($counter % 5 == 0) { echo ""; //reset the counter $counter = 1; } extract ($rows); echo ""; echo ""; $counter++; } hth bastien } ?> > Date: Mon, 3 Sep 2007 04:30:29 -0400> From: [EMAIL PROTECTED]> To: php-general@lists.php.net> Subject: [PHP] Create a matrix gallery>> hi list. I wonder if anyone can help me with this.> i have a database with the file name of several images stored in a> filesystem, and I want to create a table containing the image results of a> query.>> this is my code>> include_once("../../../connection/connection.php");> ?>> > > Image Gallery> >> > //get the thumbsnails> $getpic=mysql_query("select * from rsiis_images")> or die(mysql_error());>>> while ($rows=mysql_fetch_assoc($getpic))> {> extract ($rows);> echo "";> echo " src=".$ImageThumb.$rows['image_id'].".jpg>";> }> ?>>> >> > > >> With this code, I am able to see the thumb images with their respective link> ok, but if I have a query with 40 results, I will have a big row of images.> >> |pic1 | pic2 | pic3 | pic4 | pic5 | pic6 | pic7 | pic8 | pic9 | pic10 |> __>>> What I want to to do is insert a new after showing 5 thumb images, and> continue with the next picture on the next row.> something like this> __> |pic1 | pic2 | pic3 | pic4 | pic5 |> __> |pic6 | pic7 | pic8 | pic9 | pic10 |> __> |pic11 | pic12 | pic13 |> __ Thanks in advance.> Yamil _ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create a matrix gallery
Humani Power wrote: hi list. I wonder if anyone can help me with this. i have a database with the file name of several images stored in a filesystem, and I want to create a table containing the image results of a query. this is my code while ($rows=mysql_fetch_assoc($getpic)) { extract ($rows); echo ""; echo ""; } With this code, I am able to see the thumb images with their respective link ok, but if I have a query with 40 results, I will have a big row of images. |pic1 | pic2 | pic3 | pic4 | pic5 | pic6 | pic7 | pic8 | pic9 | pic10 | __ What I want to to do is insert a new after showing 5 thumb images, and continue with the next picture on the next row. something like this __ |pic1 | pic2 | pic3 | pic4 | pic5 | __ |pic6 | pic7 | pic8 | pic9 | pic10 | __ |pic11 | pic12 | pic13 | __ This is really quite simple... $col = 1; while ($rows=mysql_fetch_assoc($getpic)) { extract ($rows); if ($col == 1) echo ""; echo "src=".$ImageThumb.$rows['image_id'].".jpg>"; if ($col++ == 5) { echo ""; $col = 1; } } Not sure why you are using extract when you then go on to use $rows as an array. Also, you're lacking quotes around the href in the link you output, and also the src in the image. It's also missing a closing tag. And you should be using urlencode when putting values into a URL. And while I'm at it, $row is more semantically correct than $rows. Try this... $col = 1; while ($row = mysql_fetch_assoc($getpic)) { if ($col == 1) echo ''; $image_id = urlencode($row['image_id']); echo 'href="editing_image.php?pic='.urlencode($image_id).'">src="'.$ImageThumb.urlencode($image_id).'.jpg" />'; if ($col++ == 5) { echo ''; $col = 1; } } -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php