How to select multiple rows from mysql with one query and use them in php

Viewed 72513

I currently have a database like the picture below.

enter image description here

Where there is a query that selects the rows with number1 equaling 1. When using

mysql_fetch_assoc()

in php I am only given the first is there any way to get the second? Like through a dimesional array like

array['number2'][2] 

or something similar

4 Answers

It looks like the complete solution has not been suggested yet

$Query="select SubCode,SubLongName from subjects where sem=1";
$Subject=mysqli_query($con,$Query);
$Rows = array ();
while($row = mysqli_fetch_array($Subject))
{
    $Rows [] = $row;
}

The $Rows [] = $row appends the row to the array. The result is a multidimensional array of all rows.

Related