Hi, I need to pull in the details of the registrations table into my events.. Basically I need to display all the names that a particular person has registered and give it as options in the drop down menu.. Here's the code I used on the basis of this forum http://www.chronoengine.com/forums.html?cont=posts&f=2&t=11490&p=16600&hilit=get+current+user+id#p16600 and http://www.chronoengine.com/forums.html?cont=posts&f=5&t=12413&st=0&sk=t&sd=a&start=15#p22684..
Here's the code I used..
I have checked and the data seems to registering fine into the jos_chronoforms_registrations table.. in the registrations table, name is the attribute i want in the drop down menu, and cf_user_id is the attribute chronoforms inserts automatically when submitting the form (i.e. the user id of the person submitting the form...) All I get is the drop down menu, with no options in it..
What am I doing wrong here? Please help me out with this...
Thanks🙂
Here's the code I used..
<?php
$db =& JFactory::getDBO();
$user = JFactory::getuser();
$query = "
SELECT name
FROM jos_chronoforms_registrations
WHERE cf_user_id = '".$user->id."'";
$db->setQuery($query);
$rows = $db->loadObjectList();
?>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label">Participant Name</label>
<select class="cf_inputbox validate-selection" id="select_1" size="1" {cf_multiple} name="name_1">
<?php
foreach ($rows as $current) {
echo "<option value='$row'>$current</option>";
}
?>
</select>
</div>
I have checked and the data seems to registering fine into the jos_chronoforms_registrations table.. in the registrations table, name is the attribute i want in the drop down menu, and cf_user_id is the attribute chronoforms inserts automatically when submitting the form (i.e. the user id of the person submitting the form...) All I get is the drop down menu, with no options in it..
What am I doing wrong here? Please help me out with this...
Thanks🙂
Hi coolkarthik88,
You have <option value='$row'> but $row isn't defined in your code.
You should also not use *$row* or *$rows* as variable names ans ChronoForms uses those at the moment. Please use something like $t_row and $t_rows instead.
Bob
You have <option value='$row'> but $row isn't defined in your code.
You should also not use *$row* or *$rows* as variable names ans ChronoForms uses those at the moment. Please use something like $t_row and $t_rows instead.
Bob
could you put the modified code? I am not really all that good at PHP...
Hi coolkarthik88,
just as Bob said, replace every $row by $t_row and every $rows by $t_rows
Max
just as Bob said, replace every $row by $t_row and every $rows by $t_rows
Max
Here's my modified code after all the suggestions.. It still doesn't seem to work.. Please help me out with this..
<?php
$db =& JFactory::getDBO();
$user = JFactory::getuser();
$query = "
SELECT name
FROM jos_chronoforms_registrations
WHERE cf_user_id = '".$user->id."'";
$db->setQuery($query);
$t_rows = $db->loadObjectList();
?>
<select class="cf_inputbox validate-selection" id="select_1" size="1" {cf_multiple} name="name_1">
<?php
foreach ($t_rows as $current) {
echo "<option value='$current'>$current</option>";
}
?>
</select>
Hi coolkarthik88,
It doesn't help us to say that 'it doesn't work' - please be specific. What results do you get? Have you tried running the sql in PHPMyAdmin? . . .
That said, I can see that this line is incorrect
Bob
It doesn't help us to say that 'it doesn't work' - please be specific. What results do you get? Have you tried running the sql in PHPMyAdmin? . . .
That said, I can see that this line is incorrect
$user =& JFactory::getUser();
Bob
Sorry Bob... Well here's the code that's currently running on my site.. Whats actually happening is something like this.. I have a registrations form which stores the data in the table jos_chronoforms_registrations .. In this I have the default fields that chronoforms puts plus some of my fields.. what I need to do is select the names of the people entered by the currently logged in user for individual event registrations..
I am assuming the field cf_user_id is the user id of the person who submitted the form... If that's the case
I ran this query in phpmyadmin
and I got the expected output... I hope am clear on this.. Am not sure of what am doing wrong here..
I am assuming the field cf_user_id is the user id of the person who submitted the form... If that's the case
<?php
$db = &JFactory::getDBO();
$user = JFactory::getuser();
$query = "
SELECT name
FROM jos_chronoforms_registrations
WHERE cf_user_id = '".$user->id."'";
$db->setQuery($query);
$t_rows = $db->loadObjectList();
?>
<?php
foreach ($t_rows as $current) {
echo "<option value='$current'>$current</option>";
}
?>
I ran this query in phpmyadmin
SELECT name
FROM jos_chronoforms_registrations
WHERE cf_user_id = '0'
and I got the expected output... I hope am clear on this.. Am not sure of what am doing wrong here..
Hi coolkarthik88,
No problem - please make the change I put in my last posting and see if that works. If not please add one line
Bob
No problem - please make the change I put in my last posting and see if that works. If not please add one line
$db->setQuery($query);
echo "query; ".print_r($query, true)."<br /><br />"; // add this line
$t_rows = $db->loadObjectList();
This should echo out the query to the screen, see if there's anything obviously wrong and/or try pasting it into the query window in PHPMyAdmin.Bob
Query is being generated as expected, and I get the perfect output in phpmyadmin.. but the drop down is still empty..
Hi coolkarthik88,
Ah, that helps - gives me a clue where to look.
Please try replacing $db->loadObjectList(); with $db->loadResultArray();
Bob
Ah, that helps - gives me a clue where to look.
Please try replacing $db->loadObjectList(); with $db->loadResultArray();
Bob
Thanks Bob.. everything working fine now... Thanks a ton... One last question, is there anyway i can display the forms in my content pages.. I have the mambot component installed, but adding {chronocontact}registrations{/chronocontact} doesn't seem to do anything.. It just shows {chronocontact}registrations{/chronocontact} .. What exactly do I need to do?
Thanks a ton again..
Thanks a ton again..
This topic is locked and no more replies can be posted.