Piczel Piczel - 1 year ago 63
PHP Question

display as an array of array

I'm working on a school project, we have to make a web site which uses html/css and php/mysql.

I had no worries about html/css, but i have a problem with the mysql-part : i have a database Articles, with 3 cols (id, Message, id_member), i try to get only Message and id_member via

mysqli_query($con, "SELECT Messages,id_membre FROM Articles") or die(mysql_error())

and then
but this isn't what i really want to have..

i'd like to get an array of array which contains things like this :

mess1 => id_member, Message;
mess2 => id_member2, Message2;

Do you have any idea of how i can do that ? thx all, and wish you a good night from France !

Answer Source
$query = "SELECT Messages,id_membre FROM Articles"";

if ($result = mysqli_query($link, $query)) {

        while ($row = mysqli_fetch_assoc($result)) {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download