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
https://forums.phpfreaks.com/topic/94871-sql-query-results-to-php-array-in_array/
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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.