Ask Question


Need MCA Or College Project Contact Us: +91 9437911966 (Whatsapp) Students Tutorial

How to store multiple fetch data in a variable and use it in MySql where Clause

In this example we store the multiple fetch data in an array and use the array in MySql where clause to retrive data.


$category = mysqli_query($conn,"SELECT * FROM subcategory");
$category_id = [];
while($db_category  = mysqli_fetch_array($category)) {
/* print_r($category_id); */
$category_name= mysqli_query($conn,"SELECT * FROM category where id IN ('" . implode("',' ",$category_id) . "')");
while($db_category_name  = mysqli_fetch_array($category_name)) {
    echo $db_category_name["category_name"].'<br>';