I'm trying to clean up my code and I was wondering if I can place my mysql query that I call several times into an external php function that I include at the top of the file. Everytime I have tried it I have received an error, so I am wondering if it has something to do with my still being relatively new to php. It all works until I place the code in a new file (functions.php)
Here are some snippets:
This is from the page to be displayed
<?php
retreive_user_data();
while ($result = mysql_fetch_array($queryobj)) {
echo $result['about'];
}
?>
And here is the php file I'm including
<?php
function retrieve_user_data() {
$query = "SELECT * FROM users, editables WHERE users.user = editables.user";
$queryobj = mysql_query($query);
return $queryobj;
}
?>