OK so I have a php include that houses some queries and want to be able to call them when needed by just running a function. When running the function I am not getting the query returned. Not sure if I need to use a return(); in the include or not.
<?php
// include file with queries
function displayQueryOne(){
$q = "SELECT * FROM culturegrams.new_to WHERE edition = '$url' ORDER BY placement ASC";
$results= mysql_query($q) or die('could not run Query '.mysql_error());
return($results);
}
?>
<?php
//PAGE # 2 page to display query results
require('queryfile.php');
//running function from the include file
$results = displayQueryOne()
//running indpendent php while loop that will generate hmtl
while ($r = mysql_fetch_assoc($results)){
?>
<div class="top_menu"><p class="menu_text"><?php echo $r['title'];?></p></div>
<div class="mid_menu">
<p class="explore_text">
<?php echo $r['text'];?>
</p>
</div>
Yes you need to make it return like so
Then you need to call it like this