Jump to content

[SOLVED] Selecting from MySQL


timmah1

Recommended Posts

I have a database field named groups.

The value  for a user is Bowling,Cycling,Tennis,Running

 

Since the values are being inputted like that, numerous values separated by commas, how would I grab that user if someone searches just for Cycling?

 

I was trying to set up a browse feature, but it comes back "No users"

 

Here is my code

$groupsql = "SELECT * FROM users WHERE groups = '$id'";
$groupres = mysql_query($groupsql);
$numrows = mysql_num_rows($groupres);

if($numrows == 0 ) {
echo "No users within the $id group";
}
$grouprow = mysql_fetch_assoc($groupres);

echo $grouprow['first'];

 

Can someone help me out here?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/130590-solved-selecting-from-mysql/
Share on other sites

Not sure I completely understand.  So your table could have something like this:

 

user      groups

-----------------

1      Bowling,Tennis,Running

2      Bowling,Cycling,Tennis,Running

3      Bowling,Running,Cycling

 

If $id = cycling, you want to grab all of the users with Cycling in their group? So in this case it would be user 1 and 2?

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.