好的,所以我有一个包含一些查询的 php 包含,并且希望能够在需要时通过运行一个函数来调用它们。运行该函数时,我没有得到返回的查询。不确定我是否需要使用 return(); 在包含与否。
<?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>