My db table is:
author book repeat
------ ---- ------
Paulo Coelho the alchemist 2
Adam Smith The Wealth of Nations 1
I fetch data from db with the following php code:
...
$books_array[]= array(
'author'=> $row['author'],
'book'=> $row['book'],
);
But I don't know how to repeat the values according to my repeat value. How can I obtain the following array?
array
[0] => Array
(
[author] => Coelho
[book] => The Alchemist
)
[1] => Array
(
[author] => Coelho
[book] => The Alchemist
)
[2] => Array
(
[author] => Smith
[book] => The Wealth of Nations
)
Thanks!
Oups! Just thought about! That was easy!
Just added
for( $i= 0 ; $i <= $row['repeat'] ; $i++ ){
$books_array[]= array(
'author'=> $row['author'],
'book'=> $row['book'],
);
};
Hope this will be helpful to someone else :) !!!!