m'y question is: How to match multiple arrays (two, or even more) inside a foreach loop (or while)
$cat = $bdd->query('SELECT cat_name FROM categories');
$categories_list = $cat->fetchAll(PDO::FETCH_COLUMN);
$cat_id = $bdd->query('SELECT cat_id FROM categories');
$categories_id = $cat_id->fetchAll(PDO::FETCH_COLUMN);
$arrcatid = array($categories_list,$categories_id);
echo '<form method="post" action="accès/create_topic_post.php" autocomplete="off">';
echo '<label for="sujet">Sujet :';
echo '<input type="text" name="sujet" id="sujet" required autofocus>';
echo '</label>';
echo '<label for="cat">Catégories :';
echo '<select name="topic_name">';
foreach ($categories_list as $cat_name){
echo "<option value=\"$cat_name\">$catname</option>";
}
$cat_id->closeCursor();
$cat->closeCursor();
echo '</select>';
echo '</label>';
echo '<input type="submit" value="Envoyer">';
echo '</form>';
var_dump($arrcatid);
So, the goal is to match array 0 with array 1 cat_name && cat_id
Thanks a lot :D