Forum Moderators: coopster
<?php
function getNews($num)
{
$intNum = $num;
$intTotal = count($title);
$intResult = $intTotal - $intNum;
return $intResult;
}
?> I have a MySQL database. The database has a table which contains 3 field; title, date, and content. The table is opened by my script and dumps the contents into three arrays; $title, $date, and $content. Now, I know it's putting it into the arrays because $title[1] contains the contents of the first row of the title field, and so on. The database has 4 rows.
Now, this is great, but it displays my news the wrong way round. I want it to display the last row first, so I made this function to calculate the last contents of the title array. As each array uses the same identifier (i.e. $title[1] goes with $date[1] goes with $content[1]) this should produce a result that works for all the arrays, but it doesn't.
If I have
<?php echo(getNews(0));?> it actually prints '0'. If I do <?php echo(getNews(1));?> it prints '-1'. What the heck is going on?