PHP Newsletter

Join now and receive weekly updates pertianing to the world of PHP.

Polls

What do you think about the new PHPMine Design?
Awesome
Not Bad
Sucks

PHP Gigs By City

PHP Jobs By Topic

Advertisements

Php image arranging in grids?

Asked 2009-07-02 04:31:29 by anand s

I want to arrange some pictures (from database) in a tabular form.
example

1 2 3
4 5 6
7 8 9

Only 3 per row . How can i ? What is the PHP code for that ?

Anwered 2009-07-02 06:36:37 by just "JR"

Olàlà... "what is the Php code for that?"...
There is no "code" for that. You write a script!
$col = 0;
$txt = "<table>";
while ($res = mysql_fetch_array($result))
{
$img = $res['imagename'];
if ($col == 0)
$txt .= "<tr>";
$txt .= "<td><img src=\"".$img."\" /></td>";
$col++;
if ($col == 4)
{
$col = 0;
$txt .= "</tr>";
}
}
mysql_free_result($result);
if ($col != 0)
$txt .= "</tr>";
$txt .= "</table>";
echo ($txt);

Questions and answers provided by the Yahoo Answers Community.