Mysqli fetch array nth row
loops, mysql, php
Solution
You can try something like this
$arrayofrows = array();
while($row = mysqli_fetch_array($result))
{
$arrayofrows = $row;
}
You can now have
$arrayofrows[0] //(to get the first row)
$arrayofrows[1] //(2nd row)
Problem
I have the following code that fetches a single row: ``` $query = "SELECT * FROM translations WHERE iddoc = '$id' AND submitted = 1;"; $result = mysqli_query($query); $row = mysqli_fetch_array($result); ``` I know this is useful in a while loop, where you can just loop through the results. But I need to be able to grab specific rows that meet this condition. Something following this pseudo code: ``` $query = "SELECT * FROM translations WHERE iddoc = '$id' AND submitted = 1;"; $result = mysqli_query($query); $arrayofrows = mysqli_fetch_arrayofrows($result); $arrayofrows[0] //(to get the first row) $arrayofrows[1] //(2nd row) ``` and so on... How can I do this?