php array help


im storing records like this

section contains the office numbers which this file should available and my session contains the office number which user logged in

so how to check whether session office number is contain in section or not?

Who is Participating?
Ray PaseurConnect With a Mentor Commented:
You can use LIKE in the query, however this data base table is misdesigned.  Each column should contain only one value.  In other words, you should have three rows for this data instead of one.
Ray PaseurCommented:
Here is information that might be helpful.  Read the top five responses and you'll be way ahead in understanding data base design.


HTH, ~Ray
Assuming, section is an array, here is the piece of code which returns trur if logged in user section number is present in the section.

sessionSectionVar - is the section number of user stored in the session.

function myfunction($ae)
if ($ae===sessionSectionVar)
  return true;
return false;
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Lukasz ChmielewskiConnect With a Mentor Commented:
Ray's right BUT what if there are 200 offices ?
Get the value from the table like

$myarray = explode($row[section]);
if(in_array($_SESSION[office],$myarray)) echo"found";
3xtr3m3dAuthor Commented:
yeah currently i have 15 offices and also that can be increased in future
Ray PaseurCommented:
15 offices or 200 or 20,000 offices will not really matter.  If your tables are indexed correctly the size and speed of the app will be just fine.  Anyway thanks for the points and good luck with it, ~Ray
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.