I am having a problem with formatting and displaying content from a database. All the queries are fine, but when I create an array and loop through it to display the contents, nothing appears. Here is a snippet of the code
// Returns an array of information corresponding to current linkid
function get_page_content($linkid)
{
// query database for the books in a category
if (!$linkid || $linkid=='')
return false;
$conn = db_connect();
$query = "select * from pagecontent where linkid='$linkid'";
$result = @mysql_query($query);
if (!$result)
return false;
$result = @mysql_num_rows($result);
if ($result ==0)
return false;
$result = db_result_to_array($result);
return $result;
}
// Loops through the array to display the contents
function display_page_contents($page_array)
{
if(!is_array($page_array))
{
echo 'Currently no page content.';
}
else
{
foreach ($page_array as $row)
{
echo $row['pagetext'];
}
}
}
// Function that converts a MySQL result identifier into an array of results
function db_result_to_array($result)
{
$res_array = array();
for ($count=0; $row = @mysql_fetch_array($result); $count++)
$res_array[$count] = $row;
return $res_array;
}
The above code corresponds to the query, identifier conversion to an array, and the foreach{} that displays the information. Like I said before, nothing is appearing when I run these scripts.
Help, anyone?