Jump to content

Recommended Posts

I'm trying to use the SQL IN command when I query my mySQL database, but the value I am sending in it is an array, created when users selected multiple options in a list. I've been looking around and have seen a few possible solutions involving SQL, but I'm relatively new to PHP and SQL and am not quite sure how to resolve this. Any ideas?

 

matchTeam is the array:

 

$players = $_POST['matchTeam'];

$playerGames = "SELECT * FROM players WHERE playerID IN ($players)";

$playerGames_query = mysql_query($playerGames) or die(mysql_error());

$rsPlayerGames = mysql_fetch_assoc($playerGames_query);

 

Link to comment
https://forums.phpfreaks.com/topic/65669-including-array-in-sql-in/
Share on other sites

$players comes from a list where users can select multiple values. The list is created dynamically and is made up of the first and last names of players belonging to our club. You can see the page at http://www.otterstouch.com/ottersdb/select3.php. It's ugly I know!

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.