How do I make the cf_id in the foreach, print the name of a user in this table. The names of the user are of course in 'jos_users'. How do I compare them? I need a table to be shown in my chronoforms, for this I use the following code.
<?php
$user = JFactory::getUser();
// $user->id
$db = JFactory::getDBO();
$query = "SELECT * FROM `jos_chronoforms_gastenlijst` WHERE 1";
$db->setQuery($query);
$rows = $db->loadObjectList();
echo $db->getErrorMsg();
?>
<table width="100%">
<tr style="background-color: #d3d3d3"><td><strong>Naam</strong></td><td><strong>Geboortedatum</strong></td><td><strong>Betaald</strong></td><td><strong>Opmerkingen</strong></td><td><strong>Toegevoegd door</strong></td></tr>
<?php
foreach($rows AS $row) {
echo '<tr>';
echo '<td>'.$row->voornaam.' '.$row->achternaam.'</td>';
echo '<td>'.$row->geboortedatum.'</td>';
echo '<td>'.$row->betaald.'</td>';
echo '<td>'.$row->opmerking.'</td>';
// I need the name here.
echo '</tr>';
}
?>
</table>
Hi tnijman,
replace
regards
Max
replace
// I need the name here.
by $user->name;
but why do you use all this code ? if you replace $row->opmerking with opmerking then it should work the same and you dont need this PHP code at the top except the $user statement of course!regards
Max
I know that part. But I need to get the individual names from another database. With chronoforms every entry is automatically saved with the cf_user_id. I need to compare that to the id's from jos_users and then display the name. In the loop. I have this code in the form so I don't use chronoconnectivity for it.
Thanks for the reply!
Thanks for the reply!
Hi tnijman,
No problems, let me know if you have other problems to solve!
cheers
Max
No problems, let me know if you have other problems to solve!
cheers
Max
I am curious about this question.
Although I would like to retrieve the user "name" from the "cf_user_id" variable in connectivity. The database has recorded the cf_user_id after the form transferred it from user_id. Even though it is the same number I am having trouble displaying the user "name" in connectivity. Can you please assist?
Thank you very much,
George
This is an awesome tool!
Although I would like to retrieve the user "name" from the "cf_user_id" variable in connectivity. The database has recorded the cf_user_id after the form transferred it from user_id. Even though it is the same number I am having trouble displaying the user "name" in connectivity. Can you please assist?
Thank you very much,
George
This is an awesome tool!
<?php
$db = JFactory::getDBO();
$query = "SELECT id, name, username FROM `jos_users` WHERE id = `{cf_user_id}`";
$db->setQuery($query);
$rows = $db->loadObjectList();
echo $db->getErrorMsg();
?>
<?php
foreach($rows AS $row) {
echo $row->name;
}
?>
This gives me an error.. Any clue? this code is in the body of a chronoconnection.
Error:
Unknown column '63' in 'where clause' SQL=SELECT id, name, username FROM `jos_users` WHERE id = `63`
Hi tnijman,
I think you need to use straight single quotes ' ' round variables and backticks round column and table names
Bob
PS make the DB call =& too- saves duplicating the object.
I think you need to use straight single quotes ' ' round variables and backticks round column and table names
$query = "SELECT id, name, username FROM `jos_users` WHERE `id` = '{cf_user_id}'";
Bob
PS make the DB call =& too- saves duplicating the object.
$db =& JFactory::getDBO();
try this:
<?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;
?>
This topic is locked and no more replies can be posted.