Forums

DB Read Data Help

Vauthe 13 Aug, 2017
I'm trying to load a users previously entered form data by filtering the DB read using their user_id

custom code on load (this works fine):

<?php
$user = JFactory::getUser();
$userid = $user->id;
echo $userid;
?>


db read where condition:

<?php
return array($userid => 'user_id');
?>

debug:

Array
(
    [read_data11] => Array
        (
            [log] => Array
                (
                    [0] => SELECT COUNT(`table_data`.`aid`) AS `table_data.count` FROM `josxr_chronoengine_chronoforms_data_strategies` AS `table_data` WHERE `table_data`.`user_id` = '';
                    [1] => SELECT `table_data`.`aid` AS `table_data.aid`, `table_data`.`user_id` AS `table_data.user_id`, `table_data`.`created` AS `table_data.created`, `table_data`.`modified` AS `table_data.modified`, `table_data`.`instausername` AS `table_data.instausername`, `table_data`.`instapassword` AS `table_data.instapassword`, `table_data`.`st1action` AS `table_data.st1action`, `table_data`.`st1target` AS `table_data.st1target`, `table_data`.`st1hashtags` AS `table_data.st1hashtags`, `table_data`.`st1followersof` AS `table_data.st1followersof`, `table_data`.`st1geolocation` AS `table_data.st1geolocation`, `table_data`.`st2action` AS `table_data.st2action`, `table_data`.`st2target` AS `table_data.st2target`, `table_data`.`st2hashtags` AS `table_data.st2hashtags`, `table_data`.`st2followersof` AS `table_data.st2followersof`, `table_data`.`st2geolocation` AS `table_data.st2geolocation`, `table_data`.`st3action` AS `table_data.st3action`, `table_data`.`st3target` AS `table_data.st3target`, `table_data`.`st3hashtags` AS `table_data.st3hashtags`, `table_data`.`st3followersof` AS `table_data.st3followersof`, `table_data`.`st3geolocation` AS `table_data.st3geolocation`, `table_data`.`st1frequency` AS `table_data.st1frequency`, `table_data`.`st2frequency` AS `table_data.st2frequency`, `table_data`.`st3frequency` AS `table_data.st3frequency` FROM `josxr_chronoengine_chronoforms_data_strategies` AS `table_data` WHERE `table_data`.`user_id` = '' LIMIT 30;
                )

            [var] => Array
                (
                )

        )

)


If I change the order in the return array I get a missing column error on the page that doesnt load, this is the only method that has allowed me to actually debug; I just cannot get a variable to be passed to the where statement.

If I use the html version:

user_id:756


it works fine, but I obviously cannot change the string '756' to a variable using the html.

Any help appreciated as I'm reaching the end of my rope trying to this out.
Max_admin 13 Aug, 2017
Hi Vauthe,

You do not need the custom code in v6, all your need is this code in the where conditions box:
user_id:{user:id}


This is called a shortcode, its explained in the Chronoforms v6 manual and in the FAQs

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger