Hello all,
I cannot find a example to where if i have products in a mysql table and i want to use 3 columns to display the products. Then After the first 3 products are displayed then there is a new row. Anyone know a simple way to do this with smarty and PHP?
Thanks Everyone
PHP Smarty HTML columns
Moderator: General Moderators
Re: PHP Smarty HTML columns
Smarty is a template engine? anyway my code for this would be:
Code: Select all
$count=0; //set a variable to count rows
//start the while loop of mysql_fetch_array()
{
//echo what you want
$count++;//increase count
if($count==3)
{
echo "<br />"; //start a new line
$count=0;
}
}//end the while loop
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: PHP Smarty HTML columns
Actually you would want:
And you can do this in smarty with:
Code: Select all
if($count % 3 == 0)Code: Select all
{if $count is div by 3}
//or
{if $count mod 3 == 0}
//or
{if $count % 3 == 0}mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.