Solved:: Display records in repeat group with calc element

Status
Not open for further replies.
Hi,
I encouter an "issue" surely not but :
I have two list with :
the first :user info and a repeat group
the second with a request form

On the request form in the first group with pagination
A databasejoin element {request___user_lastname_raw}
And a calc element displaying all users's records in the first repeat group :

My code in the calc element :

$userId = '{request___user_lastname_raw}';
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->select('user_filename')->from('user_sheet_50_repeat')->where('parent_id = ' . $myDb->quote($userId));
$myDb->setQuery($myQuery);
$result = $myDb->loadObjectList();

foreach($result as $value){
foreach($value as $key => $data){
echo ($data) ."<br />";
}
echo "<br />";
}

And it's ok the records are displayed.
But when I click on the "next" button it's doing nothing. It's like the loop doesn't stop. I've tried with break but still the same.
I get "SyntaxError: Unexpected token C in JSON at position 0" in the console when i click on "next" button.
If I unpublish the clacl element all goes fine

What i forgot ???

Thanks for helping
 
Last edited:
Unexpected token C in JSON at position 0" in the console when i click on "next" button.
Use your browser console, check the network response in the "Network" tab. Usually you will find an error message or warning.
 
Hi Troester,
Thanks for replying
The full error in the console :

VM2472:1 Uncaught SyntaxError: Unexpected token C in JSON at position 0
at JSON.parse (<anonymous>)
at Object.<anonymous> (form.js:719)
at u (jquery.min.js?2f87ac8f8db033b9dc21a835a242fcd4:2)
at Object.fireWith [as resolveWith] (jquery.min.js?2f87ac8f8db033b9dc21a835a242fcd4:2)
at C (jquery.min.js?2f87ac8f8db033b9dc21a835a242fcd4:2)
at XMLHttpRequest.n (jquery.min.js?2f87ac8f8db033b9dc21a835a242fcd4:2)
In the network tab all is set to 200

If I replace "echo" by "return" I don't have the error but only the last record is displayed.
foreach($result as $value){
foreach($value as $key => $data){
return ($data) ."<br />";
}
return"<br />";
}
May be there is a different way to do this...
Return is better than echo wich displaying data up in the form !
 
Try with this:
PHP:
$table_data = '<table>';
foreach($result as $value){
    foreach($value as $key => $data){
        $table_data .= '<tr> . $data . </tr>';
    }
}
$table_data .= '</table>';
return $table_data;
 
Try with this:
PHP:
$table_data = '<table>';
foreach($result as $value){
    foreach($value as $key => $data){
        $table_data .= '<tr> . $data . </tr>';
    }
}
$table_data .= '</table>';
return $table_data;

Thanks a lot, i was looking for something like that.
Just modification i did replace ' by "
It's works great thanks a lot


$table_data = '<table>';
foreach($result as $value){
foreach($value as $key => $data){
$table_data .= "<tr> . $data . </tr><br>";
}
}
$table_data .= "</table>";
return $table_data;
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top