Jump to content

SQL Query results to php array + in_array


drummer101

Recommended Posts

I've got a problem that I still haven't solved thats been bugging me for weeks.

 

SELECT phpbb_user_group.group_id FROM phpbb_user_group WHERE phpbb_user_group.user_id = '".$i['user_id']."' ORDER BY phpbb_user_group.group_id DESC

 

Will return, say, 4 results. How do I store those in an array so that I can use the php function in_array to see if the value exists in the array? (A normal while loop?)

Link to comment
Share on other sites

I'm having the hardest time wrapping my head around arrays. I keep waiting for something to click into place but it just never happens =\

 

I used the code provided, and was greeted with,

Notice: Trying to get property of non-object in D:\Apache2\htdocs\*****\functions.php on line 636
Array ( [0] => )

 

From what I've gathered, $fetch would be my index and group_id would be my value.

so, $fetch[2] would be the 2nd value the query returns?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.