我想从数组$_POST["entry_of_group"]
中检索值,并将数组包含的每个值与数据库列值匹配。
即如果一个数组有3个值,那么我必须获取包含这三个值的所有行。
<?php
session_start();
$name =$_SESSION['name'];
$id = $_SESSION['id'];
include("database.php");
$run = mysqli_query($conn,"select * from users where id='$id' AND name='$name' ");
$user = mysqli_fetch_array($run);
$subject_id = $user['subject_id'];
$user_name = $user['name'];
$run1 = mysqli_query($conn,"select * from subject where sub_id='$subject_id'");
$subject = mysqli_fetch_array($run1);
$subject_name = $subject['sub_name'];
if(isset($_POST["entry_of_group"]) && !empty($_POST["entry_of_group"])){
// $_POST["entry_of_group"] is an array
$all_chapters = var_dump($_POST["chapter"]); // I want to match each and every value of var_dump array with the tuple by following query.
$query = $conn->query("select * from `question` where question_type_id =".$_POST['entry_of_group']." AND chapter_id LIKE '%$all_chapters%' ");
$rowCounts = $query->num_rows;
if($rowCounts > 0){
echo '<option value="">Select Questions</option>';
while($row = $query->fetch_assoc()){
echo '<option value="'.$row['q_id'].'">'.$row['q_name'].'</option>';
}
}else{
echo '<option value="">Question not available</option>';
}
}
?>