I have a section within a while loop tha'ts getting info from a database, and i'm wondering if theres a better/easier way of doing a set of ifs, the code at the moment is a mess
$csql_array = array(
'SELECT' => 'url, cardid',
'FROM' => array(CARDS_TABLE => 'c'),
'WHERE' => "deckid = " . $deck['deckid']
);
$csql = $db->sql_build_query('SELECT', $csql_array);
$cresult = $db->sql_query($csql); // Cache for 12 hours , 43200
while($cards = $db->sql_fetchrow($cresult))
{
if (($deck['type'] == "puzzle") and $deck['amount'] == 15)
{
$perrow = 3;
}
elseif (($deck['amount'] % 5) == 0)
{
$perrow = 5;
}
elseif (($deck['amount'] % 4) == 0)
{
$perrow = 4;
}
elseif (($deck['amount'] % 3) == 0)
{
$perrow = 3;
}
else
{
$perrow = 5;
}
$imgs[] = '<img src="'.$cards['url'].'" alt="'.$deck['name'].' '.$cards['cardid'].'" />';
$imgs[] = " ";
if (++$i % $perrow == 0){
$i=0;
$imgs[] = "<br />"; // Insert a new line
}
}