i had make php file into it function [getLink()] make connection with mysqli_connect and return link of connection to use it in another php file to get result from database with mysqli_query()
connection.php `
<?php
$userName="root";
$serverName="localhost";
$userPassword="*****";
$nameOfDataBase="ITI_System";
function getLink(){
$link=@mysqli_connect($serverName,$userName,$userPassword,$nameOfDataBase);
if(!$link){
echo "connection Error".mysqli_connect_errno();
}
return $link;
}
?>
and anothor file Login.php
<?php
include("connection.php");
$link=getLink();
$SQLstatement="select user_name from student";
$result=mysqli_query($link , $SQLstatement);
var_dump($result);
if(mysqli_num_rows($result) != 0){
while($data=mysqli_fetch_assoc($result)){
$studentNames[]=$data['user_name'] ;
}
}
$SQLstatement="select admin_name from administrator";
$result=mysqli_query($link,$SQLstatement);
var_dump($result);
if(mysqli_num_rows($result) != 0){
while($data=mysqli_fetch_assoc($result)){
$adminNames[]=$data['admin_name'];
}
}
?>
but $result is false
and mysqli_query doesn`t make sql statement and fetch data from database