$sql = "SELECT * FROM myTable WHERE name = fred "; // THIS LINE SHOULD NOT BE CHANGED
$result = mysqli_query($conn,$sql);
for ($res = array (); $res = $result->fetch_assoc(); $charDB[array_shift($row)] = $res);
then for example the 2nd result returned (just an example), I want to echo onto the screen. So something like $res[1] to get the 2nd row only.
The problem is at the moment it is treating the number in [] as the primary key for the row in the DB rather than the returned result number. Basically, I want to treat each row that is returned by its position in the array rather than the primary key in the db.
How would I achieve something like this? I have tried using fetch_object, fetch_array & fetch_row but none of them did what I wanted. I think it's something pretty basic?
Please let me know if it didn't make sense.