The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
-
bruceholt
- Veteran Member
- Posts: 100
- Joined: 2016-07-30 20:16
- Location: Australia
Post
by bruceholt » 2020-07-28 03:05
I have been trying to show the number of records in a users table but seem to be getting nowhere! If I use:
Code: Select all
<?php echo sqlValue("select count(1) from animals"); ?>
it shows the total number of records in the table but I need to only show the number of records in the table for the logged in user.
I have tried:
Code: Select all
<?php echo sqlvalue("select count(1) from animals left join membership_userrecords on pkValue=animals.id WHERE memberID='".getLoggedMemberID()."'"); ?>
but that isn't correct either>
-
jsetzer
- AppGini Super Hero
- Posts: 1817
- Joined: 2018-07-06 06:03
- Location: Kiel, Germany
-
Contact:
Post
by jsetzer » 2020-07-28 07:30
Code: Select all
$tn = "TABLENAME";
$count = sqlValue("SELECT count(*) FROM " . get_sql_from($tn, false, true));
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readability
AppGini 24.10 Revision 1579 + all AppGini Helper tools
-
bruceholt
- Veteran Member
- Posts: 100
- Joined: 2016-07-30 20:16
- Location: Australia
Post
by bruceholt » 2020-07-28 07:50
Thanks Jan, How do I place that in the php echo statement?
-
jsetzer
- AppGini Super Hero
- Posts: 1817
- Joined: 2018-07-06 06:03
- Location: Kiel, Germany
-
Contact:
Post
by jsetzer » 2020-07-28 09:39
Code: Select all
<?php
$tn = "TABLENAME";
$count = sqlValue("SELECT count(*) FROM " . get_sql_from($tn, false, true));
echo $count;
?>
or
Code: Select all
<?php echo sqlValue("SELECT count(*) FROM " . get_sql_from('TABLENAME', false, true)); ?>
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readability
AppGini 24.10 Revision 1579 + all AppGini Helper tools
-
bruceholt
- Veteran Member
- Posts: 100
- Joined: 2016-07-30 20:16
- Location: Australia
Post
by bruceholt » 2020-07-28 10:05
Terrific! Thanks Jan. Worked perfectly.
-
jsetzer
- AppGini Super Hero
- Posts: 1817
- Joined: 2018-07-06 06:03
- Location: Kiel, Germany
-
Contact:
Post
by jsetzer » 2020-07-28 10:14
Great, thanks for the feedback!
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readability
AppGini 24.10 Revision 1579 + all AppGini Helper tools
-
bruceholt
- Veteran Member
- Posts: 100
- Joined: 2016-07-30 20:16
- Location: Australia
Post
by bruceholt » 2020-07-28 22:18
Hi Jan,
Sorry to bother you again. Wondering how to expand that a bit so that it can show records based on whether a field is NULL or NOT NULL.
I have tried a few different ways but it keeps throwing errors!
-
jsetzer
- AppGini Super Hero
- Posts: 1817
- Joined: 2018-07-06 06:03
- Location: Kiel, Germany
-
Contact:
Post
by jsetzer » 2020-07-29 02:31
Code: Select all
<?php
$tn = "TABLENAME";
$count = sqlValue("SELECT count(*) FROM " . get_sql_from($tn, false, true) . " AND `field1` IS NULL AND `field2` IS NOT NULL");
echo $count;
?>
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readability
AppGini 24.10 Revision 1579 + all AppGini Helper tools
-
bruceholt
- Veteran Member
- Posts: 100
- Joined: 2016-07-30 20:16
- Location: Australia
Post
by bruceholt » 2020-07-29 03:07
You've done it again! Works great. I really appreciate your help.
Probably helpful for others as well.
-
jsetzer
- AppGini Super Hero
- Posts: 1817
- Joined: 2018-07-06 06:03
- Location: Kiel, Germany
-
Contact:
Post
by jsetzer » 2020-07-29 03:41
No prob, have a nice day!
Regards,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readability
AppGini 24.10 Revision 1579 + all AppGini Helper tools