Jump to content

Is this possible?


timmah1

Recommended Posts

I have two different fields in my database that holds an array separated by commas

sport and packages

Is it possible to check another database with what those fields hold?

 

Sport is already separated by a comma, so i don't need to do much with that, but I'm confused on how I would go about the packages.

 

This is what I have, and it obviously don't work or I wouldn't be here

$sport = $a[sport];
$package = $a[package];
$packages = explode(",", $package);
for($i = 0; $i < count($packages); $i++){
echo "$packages[0]<br>";
echo "$packages[1]<br>";
echo "$packages[2]<br>";
echo "$packages[3]<br>";
echo "$packages[4]<br>";
echo "$packages[5]<br>";
echo "$packages[6]<br>";

$sql9 = "SELECT * FROM $sport WHERE name = '$packages[0]' AND name = '$packages[1]'";

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/137606-is-this-possible/
Share on other sites

Not sure I understand what you are after.

 

If you put

 

WHERE name = '$packages[0]' AND name = '$packages[1]'";

 

then you are looking for an instance where name = something as well as something else.  That will always be nothing unless $packages[0] = $packages[1] in which case there is no point checking both.

 

If you want to select from more than one table then comma separating them is not the way to do it I think - try the SQL forum.

Link to comment
https://forums.phpfreaks.com/topic/137606-is-this-possible/#findComment-719326
Share on other sites

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.