0

i have a table containing messages that are clickable links with the following structure:

<tr><td>#</td><td><a href='messages/". $file .".php'>$file</a></</td></tr>
...

$file always has this kind of structure as document name:

Date of submission [2014-02-19] - Subject [clean the garage] - To(everybody)

the table looks like this:

Date of submission [2014-02-19] - Subject [clean the garage] - To(Everybody)
Date of submission [2014-02-15] - Subject [clean the bathroom] - To(Annita)
Date of submission [2014-02-11] - Subject [clean the livingroom] - To(Rudy)

when a user logs in the $username echo's out for example Annita or Rudy or... Now what i would like to know if it is possible to make only the <tr> 's visible for the logged in user with according to(...) name

for example when Annita is logged in, she only gets to see the <tr>'s that has her name in it, and that for example the $file <tr> with Rudy becomes invisible. When the message is to(Everybody) all users can see the message

I hope my question is clear and somebody can help or explain me... thx in advance. breaking my head over this, and i cant change the structure of the message names...

Johan
  • 211
  • 3
  • 14
  • 1
    Wouldn't it make more sense to hide the content server side using PHP, i.e., only serve up the TRs that a user is supposed to see? – Willy Feb 19 '14 at 22:53
  • yes indeed, but the messages are from an external program saved in a specific directory, and i cant adjust that program, the only thing i can do is read out the directory... – Johan Feb 19 '14 at 22:56

1 Answers1

1

Why don't you use PHP to parse the file for $username? If $username exists in the file, then you include it.

See here: PHP - parsing a txt file

E.g., I'm logged in as Rudy, so $username = 'Rudy.' Now I use PHP to find all the files that match the regular expression /To\(Rudy\)$/ (which you'll write dynamically based on $username) and include them. Javascript is definitely not the right tool for the job here.

Community
  • 1
  • 1
Willy
  • 1,055
  • 8
  • 23