I want to concatenate a number of db entries into a single string (forming a summery) I’ve come up with something that illustrates the principle, I can see that I need some sort of loop that reads each array element into the string, and then exits the loop - however my lack of experience has now got the better of me. Can you help?
- thanks in advance
- Giles
Code: Select all
// db query
$Ddb2_query = mysql_query
(
"SELECT
answer
FROM ddb
WHERE session_id = '$session_id'
AND cache = '$cacheRecall' "
);
if (!$Ddb2_query)
{
echo 'Could not run query - page.inc Ln 335 - ' . mysql_error();
exit;
}
// read query results into temp array
for($i=0; $row2 = mysql_fetch_array($Ddb2_query); $i++)
{
global $tempAnswer;
$tempAnswer[$i] = answerDecode($row2["answer"]);
}
// prepare to return above into a form using pear’s HTML_template_IT
// ANSWER is the field that will hold the result
// the concatenated $tempAnswer is where the sting should go
$template->setCurrentBlock("answer");
$template->setVariable
(
"ANSWER",
(
$tempAnswer[0] . "<br><br>" .
$tempAnswer[1] . "<br><br>" .
$tempAnswer[2] . "<br><br>" .
$tempAnswer[4] . "<br><br>" .
$tempAnswer[5] . "<br><br>" .
$tempAnswer[6]
)
);
$template->parseCurrentBlock("answer");