Php empty result for language table
I am trying to add multiple language options to the database. I created a table as follows.
And my PHP function:
public function Languages(){
$query=mysqli_query($this->db,"
SELECT * FROM languages") or die(mysqli_error($this->db));
while($row=mysqli_fetch_array($query,MYSQLI_ASSOC)) {
$data[]=$row;
}
if(!empty($data)) {
// Store the result into array
return $data;
}
}
So, I used the following code to show the result, but I get an empty result:
<?php
$language = $ReSult->Languages();
$userLanguage = 'english';
echo $language['your_family'][$userLangauge];
?>
I know if I use $language['1'][$userLanguage];
, then I get the result, but I don't want to use id here. Is there a way to do this in order to show results without using IDs?
+3
source to share