I am returning an SQL query from database using PEAR into an array.
$db_results = $db->getAll("SELECT * FROM loans ORDER BY amount, length, true_interest_cost");
If the query return results, I would like to show the first result formatted in one way and then the rest of the results formatted another way.
So, my end result would look something like this:
This is the smallest loan with the smallest length and smallest true interest cost
- Name of the loan: Superloans
- Loan amount: 100 dollars
- Length: 14 days
- TIC: 350 %
There are also these loans
- Hyperloans, 100 dollars, 14 days, 360 %
- Duperloands, 200 dollars, 15 days, 400 %
My question is:
- Is it possible to loop through a multidimensional array starting from the second array with for each in PHP or should I do it some other way?
This is what I am doing now to loop through the results.
foreach($db_results as $row)
{
print $row[1];
print $row[2];
}