问题描述
嗨
我有一个页面正在使用很多mysql查询。
有没有办法可以编写一个php文件并调用这些查询进入任何页面?
示例:
假设我在php文件中有以下50个查询
-------------------------------
include_once(db.php);
session_start();
if(isset($ _ SESSION [ 'affID'])){
}
$ sql =SELECT SUM(AffPaid)as c FROM toutcome WHERE affID ='。 $ _SESSION ['affID']。 ';
$ result = mysql_query($ sql);
$ row = mysql_fetch_array($ result);
echo£ 。 $ row ['c'];
?>
--------------- -----------------------
我可以不执行以下操作吗?
$ query1 =
include_once(db.php);
session_start( );
if(isset($ _ SESSION ['affID'])){
}
$ sql =SELECT SUM(AffPaid)as c FROM toutcome WHERE affID ='。 $ _SESSION ['affID']。 ';
$ result = mysql_query($ sql);
$ row = mysql_fetch_array($ result);
echo£ 。 $ row ['c'];
然后在任何页面中说echo $ query1?
Hi
I have a page that is using alot of mysql queries.
Is there a way i can write one php file and call these queries into any page ?
Example :
Lets say i have 50 of the below queries in a php file
-------------------------------
include_once("db.php");
session_start();
if(isset($_SESSION['affID'])) {
}
$sql = "SELECT SUM(AffPaid) as c FROM toutcome WHERE affID = '" . $_SESSION['affID'] . "'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo "£" . $row['c'] ;
?>
--------------------------------------
Can i not do the following ?
$query1 =
include_once("db.php");
session_start();
if(isset($_SESSION['affID'])) {
}
$sql = "SELECT SUM(AffPaid) as c FROM toutcome WHERE affID = '" . $_SESSION['affID'] . "'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo "£" . $row['c'] ;
then in any page say echo $query1 ?
推荐答案
这篇关于php和类,使用来自一个页面的数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!