Jump to content

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?

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.