Below are snippets from a routine that runs queries on the database, processes the information through a PHP class ("HtmlTemplateClass.php") and then outputs the applicable output on an HTML template ("TopNewsTemplateP1.php").
It all works except for the
$Page->SetParameter ( "PUBLISHED_ARTICLES", join("\n", $NoArticles) );
part. The $Admin[] "join" function and the $Reporter[] "join" functions work fine. However, they are both arrays. The $NoArticles "join" function does not work. Obviously, the $NoArticles variable is not an array so I need to treat the $NoArticles variable different than the $Admin[] and $Reporter[] array variables.
Can someone tell me how to write the snippet to replace the join("\n", $NoArticles) below?
/Note: For some reason the backslash is not working before the newline "\n" character below...?/
[code=php]
require_once "HtmlTemplateClass.php";
if ($AdminUser){ // If the user is an AdminUser output this SELECT query.
$TableName = "TopNews";
$Query = "SELECT * FROM $TableName";
$Result = mysql_db_query ($db_info[dbname], $Query, $db_connection);
while ($Row = mysql_fetch_array ($Result)){
$Admin[] = "<tr><td>".$Row["Reference"]."</td>/tr>\n";
}
}else{// If the user is a Reporter output this SELECT query.
$TableName = "TopNews";
$Query = "SELECT * FROM $TableName;
$Result = mysql_db_query ($db_info[dbname], $Query, $db_connection);
if (!$Result){
$NoArticles = "You do not have any articles.\n"; //Need to output this in the template.
}else{
while ($Row = mysql_fetch_array ($Result)){
$Reporter[] = "<tr><td>".$Row["Reference"]."</td></tr>\n";
}
}
}
$Page = new HtmlTemplate();
$Page->IdentifyTemplate ("TopNewsTemplateP1.php");
if ($AdminUser){
$Page->SetParameter ( "PUBLISHED_ARTICLES", join("\n", $Admin) );
}elseif (isset($Reporter)){
$Page->SetParameter ( "PUBLISHED_ARTICLES", join("\n", $Reporter) );
}else{
$Page->SetParameter ( "PUBLISHED_ARTICLES", join("\n", $NoArticles) ); //This part's not working.
}
$Page->CreatePage();[/code]
Thanks.
Volitics