[Solved] Display data from a loadAssocList

Status
Not open for further replies.

georgie

Member
Hello Fabrik community

Sorry for these simple PHP question, but ... I block :oops:!

I have never use it in Fabrik, I know my code begins to work because I can see good results in an array (with a var_dump or print).

But I cannot display results beautifully in my website, arrrgh. I try some foreach syntaxes, without success.

Please can you help me?

Here my code:
Code:
$monId = '{pipelines___id}';

$myDb = FabrikWorker::getDbo(false, 5);

$myQuery = $myDb->getQuery(true);

$myQuery->select('link_contact, notes')
->from('pipelines_links')
->where('pipeline_id = ' . $myDb->quote($monId));

$myDb->setQuery($myQuery);
$myResults = $myDb->loadAssocList();

Then?

THX in advance for all advices!
:rolleyes::rolleyes::rolleyes:
 
PHP:
foreach($myResults as $k=>$v){
    echo '<pre>view contact: ' . var_export($v['link_contact'], true) . '</pre>';  
    echo '<pre>view notes: ' . var_export($v['notes'], true) . '</pre>';
}
 
Thank you.
With your help and an old thread (http://fabrikar.com/forums/index.php?threads/solved-calc-element-to-return-multiple-results.41128/), I found the perfect solution I think, here:
Code:
$monId = '{pipelines___id}';

$myDb = FabrikWorker::getDbo(false, 5);

$myQuery = $myDb->getQuery(true);
// Requete de recuperation de la valeur concernee en fonction de l id d'origine
$myQuery->select(array('link_contact, notes'))
->from('pipelines_links')
->where('pipeline_id = ' . $myDb->quote($monId));

$myDb->setQuery($myQuery);
$myResults = $myDb->loadObjectList();


$list = array();
foreach ($myResults as $row)
{
    $list[] = "<p style='margin-bottom:0px'>" . $row->link_contact . " " . $row->notes . "</p>";
}
return  implode($list)  ;

#Fabrik
 
Last edited:
It all depends on what you want to achieve and how much you can, of course.
What I've written is just a guideline, not a decision.

Please, close this thread, if you resolve the problem.
 
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