我的数据库表是:
author book repeat
------ ---- ------
Paulo Coelho the alchemist 2
Adam Smith The Wealth of Nations 1
我使用以下php代码从db获取数据:
...
$books_array[]= array(
'author'=> $row['author'],
'book'=> $row['book'],
);
但我不知道如何根据我的重复值重复这些值。我如何获得以下数组?
array
[0] => Array
(
[author] => Coelho
[book] => The Alchemist
)
[1] => Array
(
[author] => Coelho
[book] => The Alchemist
)
[2] => Array
(
[author] => Smith
[book] => The Wealth of Nations
)
谢谢!
答案 0 :(得分:0)
Oups!想想!那很简单!
刚刚添加
for( $i= 0 ; $i <= $row['repeat'] ; $i++ ){
$books_array[]= array(
'author'=> $row['author'],
'book'=> $row['book'],
);
};
希望这对其他人有帮助:) !!!!