I'm learning PHP and MySQL and I have a question.
<?php
require('../connect_db.php');
$q='SELECT price FROM towels WHERE color = "Red"';
$r=mysqli_query($dbc, $q);
while($row=mysqli_fetch_array($r, MYSQLI_NUM)) {$var=$row[0];}
In my case, I have towels with different prices that have color="Red". But it seems that the output in $var is only one of those prices.
It doesn't even seem to be always the largest or smallest price, or the price belonging to the first PrimaryKey in my table, or anything else that would seem intuitive.
so what is going on here?
Thanks.