I tried to do a standard search of this topic, but it is hard to explain with just search words. This is probably really really really simple to solve as well.
Anyways, I am pulling results from my database where collegeID = $collegeID.
Say I want to display a college on my site with the collegeID that equals 200.
This is displays correctly if there is only 1 college ID in the field...say collegeID = 200.
But if there are more college ID's in the field...say collegeID = 200, 210, 220, it will not display this because, technically it won't really equal.
How do you assign collegeID to $collegeID where that dont have to equal, but have that value within the field?
I hope you understand.
Thanks for the help in advance.
Variables
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Variables
This is bad database design number one. But probably a quick way to do it if you have to is this:
If you just used LIKE '%collegeID%' without the commas, then of course 2000 would match 200 and 200 would match 2, etc...
Code: Select all
SELECT * FROM table_name WHERE collegeID = '$collegeID' OR collegeID LIKE '%$collegeID,%' OR collegeID LIKE '%, $collegeID%'mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.