How to set a single query to loop on all tables in my MySql database?
Have tried this and got tables in print_r()
function landing() {
$db_handle = new DBController;
$games_table_array = $db_handle -> runQuery("SHOW TABLES LIKE '%games'");
echo '<pre>';
print_r($games_table_array);
}
I got all tables
Array
(
[0] => Array
(
[Tables_in_h2b (%games)] => apk_games
)
[1] => Array
(
[Tables_in_h2b (%games)] => pc_games
)
[2] => Array
(
[Tables_in_h2b (%games)] => psp_games
)
)
But now I want to make a foreach loop again on each table but I'm confused on what to do
Tried this but
foreach ($games_table_array as $game_table) {
$games_array = $db_handle -> runQuery("SELECT * FROM '$games_table_array[$game_table]['?SHOULD BE COLUMN NAME BUT IT'S A TABLE? WHAT TO WRITE HERE']' WHERE command > 20 ORDER BY command DESC LIMIT 10");
foreach ($games_array as $key => $value) {
?>
<div class="container">
<!-- //! To IMPLEMENT directly add to cart shop
<a href="home?t=games-pc">
<img src="assets/images/games_pc/<?php echo $games_array[$key]["img"]?>" alt="">
</a> -->
<img src="assets/images/games_pc/<?php echo $games_array[$key]["img"]?>" alt="">
<span><?php echo $games_array[$key]["command"]?> achats</span>
</div>
<?php
}
}