Forums: Report that shows on the current users records - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Report that shows on the current users records SQL Where User_id = $session_user_id

#1 User is offline   zamzam2112 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 28-July 08

Posted 03 August 2008 - 12:28 AM

I made another table called _user_students and followed the pattern of the user_addresses so a user can add more than 1 student to their account.

But with this they can only see thier own students too.

Now I'm trying to make a report (users_Report.php) and it it groups by user_id from the table users.


The report and query look good, but it shows everyones _user_students in the report. I only want to show the current users id. I have the permission in the PHPrunner set for users to only see thier own data, but I guess reports and especially my custom report isn't looking at this.

I tried to add a WHERE clause in the SQL designer but it doesn't let me go any further.

last part of my Query:
`_user_students`.sign_medical,
`_user_students`.sign_name
FROM users
RIGHT OUTER JOIN `_user_students` ON `_user_students`.user_id = users.user_id
WHERE users.user_id = ".$_SESSION["UserID"]."


Now I think it has to be done in users_reports_events.php


// Report page: Before SQL query
function BeforeQueryReport(&$strSQL,&$strWhereClause,&$strOrderBy)
{
WHERE users.user_id ".$_SESSION["UserID"]."

//**********  Custom code  ************
// put your custom code here


} // function BeforeQueryReport


Do I add something here? Or is there another setting that I can do for this?

Thanks!

Bob
0

#2 User is offline   zamzam2112 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 28-July 08

Posted 03 August 2008 - 01:45 AM

Modified: users_Report_variables.php (a custom view and sql query based on my users table and a right join to my students table.)

Found In the Output/Include folder:

(Used Dreamweaver8 for editing)

1st. dimmed a string for safety (around line 9)
// adding this for SFBC 
$strWhereid =  $_SESSION["IDUser"];


Then added the Where Clause that I wanted (around line 17 of the php file)
$gsqlWhere="users.user_id = $strWhereid ";


And now the logged in user only sees their students.


I'm posting my own answer, but I still could use help if there are any security problems with doin it this way.

I will share my Project info on a test site later.
Thanks
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users