Forums

Show user name

fmejia 03 Mar, 2009
here I go again :$ sorry to bother you guys this much... 😶

With my chronoforms registration profile plugin I was able to save the 'user id' of the user who submits the form, but with my chronoconnectivity I need to show the name of that user and not only the ID (along with other information saved from the form😶 ), I have the php query to get the names but I don't know where or how to put it in my chronoconnectivity report. I would really appreciate your assistance with this I am sure is probably something really simple but as I said before I am a newbie... 😢


$sql = "SELECT `jos_users`.`name`\n"
    . "FROM `jos_users`, `jos_chronoforms_chr_talisma_tracker`\n"
    . "WHERE (`jos_chronoforms_chr_talisma_tracker`.`cf_user_id` = `jos_users`.`id`)\n"
    . " LIMIT 0, 30 ";
GreyHead 03 Mar, 2009
Hi fmejia,

It probably needs to go in the head section if you only need one user per page.

You can get the Joomla Name and Username from the User Object - is there a different name stored in the talisma_tracker table?

Bob
fmejia 03 Mar, 2009
Hi Bob... thank you for your answer.... In fact what I need is a whole table of names but I didn't know how to get the name with chronosforms it stores something called 'uid' but I don't know how to get the name from it (it shows on the table something like: IYmFjZDc4NzNjMGU0)
GreyHead 03 Mar, 2009
Hi fmejia,

The ChronoForms uid is just a Unique ID for the record - nothing to do with users.

Bob
fmejia 03 Mar, 2009
thank you again bob, how can I get the user name? either saved on the table from the chronoform or retrieved with chronnoconectivity merging info from both tables?
fmejia 03 Mar, 2009
hi bob I was able to find in this post what I need to do and it shows the names but no in the table as I want them

http://www.chronoengine.com/forums.html?cont=posts&f=12&t=12163

now I added the code shown on that post to my chronoconnectivity connection


    <?php
    $db =& JFactory::getDBO();
    $query = "SELECT id, name, username FROM #__users WHERE id = '".$row->cf_user_id."'";
    $db->setQuery($query);
    $row = $db->loadObject();
    echo $db->getErrorMsg();
    echo $row->name;
    ?>


and what I get is an empty table with the names (that I want) at the top, I added a screenshot of what I need to get and what I am getting.

here is what I need to get: [attachment=1]form1.jpg[/attachment]

and here is what I am getting (the column called RS should be the name, instead of the ID): [attachment=0]form2.jpg[/attachment]
Max_admin 03 Mar, 2009
are you sure that the column name has the name and not the id ? your code looks correct!!

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
fmejia 03 Mar, 2009
the code gives me the names as you can see in the second image but I just don't know how to put them in the table... so they can show as the column "RS" shows on the first image
Max_admin 03 Mar, 2009
oh, mixed images, this is an HTML issue now, you need to put the
echo $row->name; 
in the correct place in the body HTML, and please change $row to something else in your code because this may make problems!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
fmejia 03 Mar, 2009
thank you .. the thing is that I don't know the syntaxis or how to put it in the table, here is my code, maybe you can give me a hande, cause for what I've seen in other posts I think it should be in a loop or something but I honestly have no clue 😶 I am very unsavvy on this.

<tr<?php if ($i % 2) echo ' style="background-color: #EBEBEB;"';?>>

<td>{edit_record} {sessionid}</td>
<td>{recordtime}</td>
<td>{case}</td>
<td>{tag_ord}</td>
<td>{dps}</td>

    <?php
    $db =& JFactory::getDBO();
    $query = "SELECT id, name, username FROM #__users WHERE id = '".$row->cf_user_id."'";
    $db->setQuery($query);
    $row = $db->loadObject();
    echo $db->getErrorMsg();
    echo $row2->name;
    ?>

<td>/////here is where I need to put the echo $row2->name value for each row/////</td>
<td>{agent_name}</td>

<?php $i++ ?>
</tr>
Max_admin 04 Mar, 2009
Hi,

All you need to do is to replace the ///here is I want to...//// with the PHP code block:
<?php
    $db =& JFactory::getDBO();
    $query = "SELECT id, name, username FROM #__users WHERE id = '".$row->cf_user_id."'";
    $db->setQuery($query);
    $row = $db->loadObject();
    echo $db->getErrorMsg();
    echo $row2->name;
    ?>


Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
fmejia 04 Mar, 2009
sorry Max to bother this much I am sure I am missing something.. I put the code where you told me and I get a table with the "edit" link and nothing else (find the screenshot attached:

[attachment=0]stillnotworking.jpg[/attachment] here is my code:

Header:

<font face="Century Gothic" size="4" color="#000080"><b>Talisma Tracker for Resolution<br>
<u>All Records</u></b><br>
<br>
<br>
</font>

<table style="text-align: left; width: 100%; font-family: Calibri; font-size: 10pt; color: #000000" border="0" cellpadding="2" cellspacing="0">

<tr>
<td style="font-weight: bold; width: 13%;border-left-style:solid; border-left-width:1px; border-right-style:solid; border-right-width:1px; border-bottom-style:solid; border-bottom-width:1px">Session ID</td>
<td style="font-weight: bold; width: 18%;border-right-style:solid; border-right-width:1px; border-bottom-style:solid; border-bottom-width:1px">Date / Time</td>
<td style="font-weight: bold; width: 11%;border-left-style:solid; border-left-width:1px; border-right-style:solid; border-right-width:1px; border-bottom-style:solid; border-bottom-width:1px">Case#</td>
<td style="font-weight: bold; width: 16%; border-left-style:solid; border-left-width:1px; border-right-style:solid; border-right-width:1px; border-bottom-style:solid; border-bottom-width:1px">Service Tag / Order</td>
<td style="font-weight: bold; width: 10%;border-left-style:solid; border-left-width:1px; border-right-style:solid; border-right-width:1px; border-bottom-style:solid; border-bottom-width:1px">DPS#</td>
<td style="font-weight: bold; width: 8%;border-left-style:solid; border-left-width:1px; border-right-style:solid; border-right-width:1px; border-bottom-style:solid; border-bottom-width:1px">RS</td>

<td style="font-weight: bold; width: 21%;border-left-style:solid; border-left-width:1px; border-bottom-style:solid; border-bottom-width:1px">Agent Name</td>
</tr>



Body:

<tr<?php if ($i % 2) echo ' style="background-color: #EBEBEB;"';?>>

<td style="width: 13%;border-left-style:solid; border-left-width:1px; border-right-style:solid; border-right-width:1px; border-top-style:solid; border-top-width:1px">{edit_record} {sessionid}</td>
<td style="width: 18%;border-right-style:solid; border-right-width:1px; border-top-style:solid; border-top-width:1px">{recordtime}</td>
<td style="width: 11%;border-left-style:solid; border-left-width:1px; border-right-style:solid; border-right-width:1px; border-top-style:solid; border-top-width:1px">{case}</td>
<td style="width: 16%;border-left-style:solid; border-left-width:1px; border-right-style:solid; border-right-width:1px; border-top-style:solid; border-top-width:1px">{tag_ord}</td>
<td style="width: 10%;border-left-style:solid; border-left-width:1px; border-right-style:solid; border-right-width:1px; border-top-style:solid; border-top-width:1px">{dps}</td>

<td>
    <?php
        $db =& JFactory::getDBO();
        $query = "SELECT id, name, username FROM #__users WHERE id = '".$row->cf_user_id."'";
        $db->setQuery($query);
        $row = $db->loadObject();
        echo $db->getErrorMsg();
        echo $row2->name;
        ?>
</td>

<td style="width: 21%;border-left-style:solid; border-left-width:1px; border-top-style:solid; border-top-width:1px">{agent_name}</td>
<?php $i++ ?>
</tr>



Footer:

</table>
<?php $i++ ?>


<br>
<br>
<br>
<br>
<br>

        <script type="text/javascript">
        window.addEvent('domready', function() {
           var limit_select = $('limit').options;
           if ( !limit_select ) return;
           for ( var i = 0; i < limit_select.length; i++ ) {
                if ( limit_select[i].value == 0 ) {
                   limit_select[i].value = 250;
                   limit_select[i].innerHTML = '250';
                }
           }
        });
        </script>
    <div align="left">{pagination}</div>
    <br />
Max_admin 09 Mar, 2009
well, I think there is some error in the php code, try this :

    <?php
        $db =& JFactory::getDBO();
        $query = "SELECT id, name, username FROM #__users WHERE id = '".$row->cf_user_id."'";
        $db->setQuery($query);
        $row2 = $db->loadObject();
        echo $db->getErrorMsg();
        echo $row2->name;
        ?>
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
yahhr857 11 Nov, 2009

well, I think there is some error in the php code, try this :

    <?php
        $db =& JFactory::getDBO();
        $query = "SELECT id, name, username FROM #__users WHERE id = '".$row->cf_user_id."'";
        $db->setQuery($query);
        $row2 = $db->loadObject();
        echo $db->getErrorMsg();
        echo $row2->name;
        ?>



Sorry to catch this thread so late, but I am having the same issue and tried this same code with the same result (blanks where there should be names). I also see nothing at issue with the code but cannot get it to work. I tried a similar code block for a pull-down menu that worked fine, but this just doesn't want to go.

Any solutions? or is it a configuration issue?
GreyHead 11 Nov, 2009
Hi Yahhr,

A bit late here so I've only taken a quick look. Is this inside the ChronoConnectivity body? If so you can't run MySQL there as there's already a live query running the loop. At least that how I remember this from a previous experiment.

You really need a compound query on the joined fields but that's not directly supported by this version of CC.

I'll see if I can find a fix in the morning but I'm not sure that there is a simple one.

Bob
This topic is locked and no more replies can be posted.