I have a phpMyAdmin database table where I have set of records. Now my table is named user_calculation_data
and then this is my MYSQL line:
<code>$username="Alex212";
$chosesql="SELECT id,calctag,data,query,savetime,name from user_calculation_data where username='$username';";
</code>
<code>$username="Alex212";
$chosesql="SELECT id,calctag,data,query,savetime,name from user_calculation_data where username='$username';";
</code>
$username="Alex212";
$chosesql="SELECT id,calctag,data,query,savetime,name from user_calculation_data where username='$username';";
Here, the column named id
is the primary key of my table. It is unique and gets auto incremented. But whenever, I use the following code:
<code>$result=$conn->query($chosesql);
$datarows=$result->fetch_all(MYSQLI_ASSOC);
</code>
<code>$result=$conn->query($chosesql);
$datarows=$result->fetch_all(MYSQLI_ASSOC);
</code>
$result=$conn->query($chosesql);
$datarows=$result->fetch_all(MYSQLI_ASSOC);
and try to access id
by this:
echo $datarows[0]["id"];
It says null. Moreover, whenever, I output the whole array through something like this:
<code>var_dump($datarows[0]);
</code>
<code>var_dump($datarows[0]);
</code>
var_dump($datarows[0]);
It shows me that $datarows[0]
has every columns in it, except the id
column. But why is the case?
1