Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

store fetched data into array php

<?php
$host='localhost';
$username='root';
$password='';
$conn=mysqli_connect($host,$username,$password,"student");
$category = mysqli_query($conn,"SELECT * FROM subcategory");
$category_id = [];
$i=0;
while($db_category  = mysqli_fetch_array($category)) {
    $category_id[]=$db_category["category_id"];
    
}
/* print_r($category_id); */
$category_name= mysqli_query($conn,"SELECT * FROM category where id IN ('" . implode("',' ",$category_id) . "')");
    $i=0;
while($db_category_name  = mysqli_fetch_array($category_name)) {
    echo $db_category_name["category_name"].'<br>';
    
}
?>
Source by www.studentstutorial.com #
 
PREVIOUS NEXT
Tagged: #store #fetched #data #array #php
ADD COMMENT
Topic
Name
2+5 =