Karan K
Karan K

Reputation: 21

The values that are being printed are only of array[0]

function DisplayOE(){
$link = mysqli_connect('local','kw','pass'); //Creates a connection
if(!$link){die(' Could not connect: '.mysql_error());}
mysqli_select_db($link,'kvw') or die(mysqli_error());
$rows = mysqli_query($link, "SELECT * FROM CreateOE");
$oe = mysqli_fetch_array($rows);
//$OEquestions = 

    return $oe;
    mysqli_close($link);
}

//$result = DisplayOE();

print_r(array_values(DisplayOE()));

Hello everyone, I have a table in phpmyadmin. I am trying to return the data from the whole table as an array. Whenever I try to test it it only prints out all the values of [0] => Array. So it only prints out the values of 1 row. How can I make it print out all the rows, so I know it is working properly?

Upvotes: 0

Views: 27

Answers (1)

Jaime
Jaime

Reputation: 1410

You need to do:

while ($row = mysqli_fetch_array($rows)) {

}

Upvotes: 2

Related Questions