Within a function I have declared a variable and given it a value based on a database query. (see code below)
if(!$next){
$next=0;
}
$rpp = 20; //results per page
$query = "select * from header where parent = $postid order by posted desc limit $next, $rpp";
$result = mysql_query($query);
Within a different function I would like to test whether this variable has a value (see below)
if($result){
$num_msgs = mysql_numrows($result);
$prev = $next - $rpp;
$next += $rpp;
echo"<tr><td colspan='3' bgcolor = '#ffffff' align = 'right'>";
if($next <= $num_msgs)echo"<a href=\"forum.php?next=$next\">Older Messages</a>";
if(($next <= $num_msgs) && ($prev >= 0))echo" | ";
if($prev >= 0)echo"<a href=\"forum.php?next=$prev\">Newer Messages</a>";
echo"</td></tr>";
}
Problem is the 2nd function doesn't appear to see the original variable and therefore doesn't execute the code. Is there some way I can pass the variable and its contents to the2nd function to allow this code to execute?
Appreciate your suggestions
David