ok
Function created variables are throw away variables - So after the function is run they are dropped!
So unless they are assigned to something - ie a class or a session or you return something from your function they will be lost.
So to keep a single variable you can always return it. Something like this will do (I haven't tested the code though) but the concept is sound - you create an array of all the newstories and return that array when the function is called.
function news(){
$sql = "SELECT * FROM newsmessages";
$result = mysql_query($sql, $link) or die(mysql_error());
$newsData = Array();
while ($newsfetch = mysql_fetch_array($result)) {
$newsData[] = Array (
'news' => $newsfetch['Text'],
'newstitle' => $newsfetch['Title'],
'newsdate' => $newsfetch['Date'])
}
return $newsData;
}
// To call news and get the data do this:
$newsdata = news();