• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

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?

2 Solutions
Ray PaseurCommented:
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;
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Lukasz ChmielewskiCommented:
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now