Counting records for a dashboard total only for the logged in user December 17, 2020, 09:39:59 PM Hello There,I would like to counting records for a dashboard total only for the logged in user. I try this "SELECT COUNT(*) AS num FROM hostingpakketten" But the tabel has an username in it so i need to only show the users rows. and not all..Please help.. Quote Selected
Re: Counting records for a dashboard total only for the logged in user Reply #1 – December 18, 2020, 04:20:18 PM @pvisser please limit it by adding the MySQL where clause to your query. Example: Code: [Select]"SELECT * FROM table WHERE userid =".USER_ID Quote Selected
Re: Counting records for a dashboard total only for the logged in user Reply #2 – December 19, 2020, 11:18:38 AM Hi There, Thanks but the counter seas 0 even there is one reccord..I Try this :"SELECT COUNT(*) AS num FROM hostingpakketten WHERE Naam_Klant=" .USER_ID PLease advice Quote Selected
Re: Counting records for a dashboard total only for the logged in user Reply #3 – December 19, 2020, 06:24:00 PM @pvisser is it a user id you store in this field Naam_Klant or a user name? if it is a user id, your query should work, if not it wouldn't work. If it is a user name, please use USER_NAME in place of USER_ID, and also the view helper for functions and variables you can use. Quote Selected
Re: Counting records for a dashboard total only for the logged in user Reply #4 – December 20, 2020, 09:11:08 AM Hello again. Yes it is the username stored in the field but when I user USER_NAME I see an error 500. when I use the USER_iD then it stil counts all records instead the records from the user logged inPlease advise Quote Selected
Re: Counting records for a dashboard total only for the logged in user Reply #5 – December 20, 2020, 10:36:52 AM @pvisser make sure u are not missing the dot before the variable, please look at query properly and the instructions above, thanks. Quote Selected
Re: Counting records for a dashboard total only for the logged in user Reply #6 – December 20, 2020, 11:47:23 AM I Did like this right?"SELECT COUNT(*) AS num FROM hostingpakketten WHERE Naam_Klant=" .USER_NAME This is the Table : hostingpakketten This is the field in the table te usename is saved in : Naam_KlantSo if PIET is logged in, i only want to count the records with PIET his name in field : Naam_KlantPlease Advice. Quote Selected
Follow-ups How can I auto fill fields from the "user" table Re: Counting records for a dashboard total only for the logged in user Reply #7 – December 20, 2020, 08:29:10 PM @pvisser send me your TeamViewer details via PM, thanks. Quote Selected
Re: Counting records for a dashboard total only for the logged in user Reply #8 – December 21, 2020, 06:27:54 PM Hello there thank you for helping out. I noticed that I had to use user_id to store in the table instead of use_name then I can query the name in the table. The only think I would like to know is : How can I auto fill fields from the user table in a table hostingpacks with a field like eg Customer In the Table user I have IDUsernamePasswordRoleIn the table Hostingpacks I have :Username (as (Selectbox) with the list from the table user)Customer (I want to auto fill with the username if I select a username from the above field from the table user)Can you please advice me with a sample how to do this? That would be great..Thank you so mutch. I love PHPRad. More than Appgini I own also Quote Selected