EasyCFM.COM ColdFusion Forums / Coding Help! / Show info based on login

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Show info based on login

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

MIGhunter
08-01-2013 @ 2:01 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 570
Joined: Apr 2006

I'm trying to get a cfgrid to only display information
based on a logged in user.  I'm using an example out of
the CWACK volume 1 book.  

Here is the cfc code that works if I comment out some
stuff.  If I change the where clause to be

where users.userID = session.userID

I get an error.

<!--- Browse characters --->
<cffunction name="browse"
             access="remote"
             returntype="struct"
             hint="Browse method for Ajax grid">

   <cfargument name="page"
               type="numeric"
               required="yes">

   <cfargument name="pageSize"
               type="numeric"
               required="yes">

   <cfargument name="gridsortcolumn"
               type="string"
               required="no"
               default="">

   <cfargument name="gridsortdir"
               type="string"
               required="no"
               default="">


   <!--- Local variables --->
   <cfset var characters="">

   <cfquery datasource="#ds#"
            name="characters">

  SELECT users.userID, users.userName, users.userEmail,
users.Roles<!---,
          characters.characterID,
characters.userID, characters.characterName--->

  FROM users<!---, characters--->
  <!---WHERE users.userID=characters.userID
   <cfif ARGUMENTS.gridsortcolumn NEQ ""
         and ARGUMENTS.gridsortdir NEQ "">

      ORDER BY #ARGUMENTS.gridsortcolumn#
#ARGUMENTS.gridsortdir#
    </cfif>--->
   </cfquery>

   <!--- And return it as a grid structure --->
   <cfreturn QueryConvertForGrid(characters,
                                 ARGUMENTS.page,
                                 ARGUMENTS.pageSize)>

</cffunction>


Here is the grid code

<cfform>
<cfgrid name="userGrid"
        width="1000"
        format="html"
        pagesize="10"
        striperows="yes"
        bind="cfc:characters.browse({cfgridpage},
                                {cfgridpagesize},
                                {cfgridsortcolumn},
                                
{cfgridsortdirection})"
>

   <cfgridcolumn name="userID"
                 display="no">

   <cfgridcolumn name="userName"
                 header="User Name"
                 width="300">

   <cfgridcolumn name="userEmail"
                 header="Email"
                 width="300">

   <cfgridcolumn name="Roles"
                 header="Role"
                 width="400">

</cfgrid>
</cfform>
<a href = "logout_process.cfm">[Log Out]</a>


Any idea what's causing it to erroror how to make it
only display the logged in user's information?

Webmaster
08-09-2013 @ 1:32 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

Shouldn't:

users.userID = session.userID

be:

users.userID = #session.userID#

?

Pablo Varando
Senior Application Architect
EasyCFM.COM, LLC.

904.483.1457 \\ mobile
webmaster@easycfm.com \\email

\m/ (>.<) \m/
--- rock on ---


Website Designed and Developed by Pablo Varando.