drummer101 Posted March 7, 2008 Share Posted March 7, 2008 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 More sharing options...
scvinodkumar Posted March 7, 2008 Share Posted March 7, 2008 make a while and store each value in a array. For example as per your code, $query ="query"; $result = mysql_query($query); while($fetch=mysql_fetch_object($result)) { $array_name []= $fetch->group_id; } Try this.. Link to comment https://forums.phpfreaks.com/topic/94871-sql-query-results-to-php-array-in_array/#findComment-485980 Share on other sites More sharing options...
drummer101 Posted March 7, 2008 Author Share Posted March 7, 2008 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 https://forums.phpfreaks.com/topic/94871-sql-query-results-to-php-array-in_array/#findComment-486031 Share on other sites More sharing options...
drummer101 Posted March 7, 2008 Author Share Posted March 7, 2008 bump to try and get a grip on things =\ Link to comment https://forums.phpfreaks.com/topic/94871-sql-query-results-to-php-array-in_array/#findComment-486196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.