Jump to content

Database To Shuffled Data


Johnny2

Recommended Posts

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! :) :) :)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...