I am new to PHP. I am working on a project and tying to learn PHP. But I am facing a hectic problem which i don't know why this happening. I have a table in database name gift_items And I am trying to fetch data of that table through PHP code. But when run the query in php and my browser show me some data not the complete data from data base.
Here is my ServerConnection.php
<?php
$Server = 'localhost';
$username = 'root';
$password = '';
$database = 'db_gifters';
$connection = mysqli_connect($Server,$username,$password);
if($connection)
{
mysqli_select_db($connection,$database);
}
else
{
echo "Could not connect to server";
}
?>
And part of php code in index.php where i am actually running the query.
<?php
$Listquery = "select giftname, gifttype from gift_items order by
gifttype,giftname";
$gifttype_query = "select distinct gifttype from gift_items";
$ListqueryResult = mysqli_query($connection,$Listquery);
$gifttype_queryResult = mysqli_query($connection,$gifttype_query);
$Listresult = mysqli_fetch_array($ListqueryResult);
$gifttype_result = mysqli_fetch_array($gifttype_queryResult);
foreach ($gifttype_result as $value)
{
echo $value;
}
?>
The output is as given below: Its gives me the output of same data twice instead of two different data values. As given

Here i am also attaching the screen shoot of result in database with same query adn it gives me accurate result but in php code its gives me same value twice as output.
Can someone resolve this issue or tell me what is the actual problem in my script code ??? is there any logical error.??
$gifttype_result = mysqli_fetch_array($gifttype_queryResult);to$gifttype_result = mysqli_fetch_array($gifttype_queryResult, MYSQLI_ASSOC);while($row = mysqli_fetch_array($gifttype_queryResult, MYSQLI_ASSOC)) { echo $row['gifttype']; }