Johnny2 Posted March 4, 2013 Report Share Posted March 4, 2013 I'm trying to grab data about products stored in my database, then shuffle the array contents to be able to later display the products in a random fashion. I'm having trouble understanding the initial data-grab, and therefore the initial array I need to work with. For instance: $sql=mysql_query("SELECT * FROM products"); Is $sql a variable that now holds an array of arrays from the info from my database? I assumed that, but when I var_dump it, it gives me: resource(5, mysql result) So, then I put in : $productArray = mysql_fetch_array($sql); echo var_dump($productArray); This gives me an array, BUT only for the first item-array, when there should be several arrays in $sql somewhere. So, where in the heck is all the data I got from the database query (for all the other products)? Can someone please help me understand whatever concepts I am missing here? Thank you tons! :) Quote Link to comment Share on other sites More sharing options...
Strider64 Posted March 5, 2013 Report Share Posted March 5, 2013 I think you have to do something like the following: while ($row = mysql_fetch_array($result, MYSQL_NUM)) { printf("ID: %s Name: %s", $row[0], $row[1]); } You can find more info here: PHP Manual Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.