Dear all:
I am just wondering is there a way to have a global varialbe in a PHP page?
I have 2 php pages which are the two frames of a webpage. The page on the left have several buttons which will generate different msgs and pass to the page on the right.
The right page will generate different SQL stmts according to the msg it received from the left page and display the search results.
There is also a text box and a button called "Refresh" on the right page. So that when users type a number, say "5", in the text box and click the "Refresh" button, the previously displayed results will be reduced to the number of rows according to the number in the text box.
Here is some snippets of my code:
[
//This is to display search results
if ($Msg == "NewUsr"
{//Msg is received from left page
$SQLStmt = "Select datetime, nick, mobile from users order by datetime desc";
DisplayResults($SQLStmt);}
if ($Msg == "AllUsr"
{
$SQLStmt = "Select nick, mobile, datetime from users order by nick asc";
DisplayResults($SQLStmt); }
//This means to refresh the results, the text box for usr
//to input number is named as "txtNumber".
//The code is:
if($txtNumber != ""
{
$SQLStmt.= " limit 0, ".$txtNumber;
DisplayResults($SQLStmt); }
]
I intend to append clause "limit 0, '$txtNumber' " to the end of the SQL Stmt which is lastly executed. However, that SQL Stmt seems don't remain after executing. So I really want a some kind of global variable which can hold the value of that SQLStmt.
I tried defining the variable SQLStmt at the beginning of PHP script. I also tried defining a variable named 'G_SQLStmt' at the beginning and passed the value of SQLStmt to it. Here is how I do it:
[
if ($Msg == "RecentMsg"
{
$SQLStmt = "Select sender, mobile, datetime, messages from mo_messages order by datetime desc";
$G_SQLStmt = "Select sender, mobile, datetime, messages from mo_messages order by datetime desc";
DisplayResults($SQLStmt);}
]
However, neither of them work. Can someone help me on this?
BTW, the 'txtNumber' text box and 'Refresh' button are in a form called 'frmRefresh' on the right page. So the value of 'txtNumber' is passed to the right page itself and process accordingly.
I am just wondering is there a way to have a global varialbe in a PHP page?
I have 2 php pages which are the two frames of a webpage. The page on the left have several buttons which will generate different msgs and pass to the page on the right.
The right page will generate different SQL stmts according to the msg it received from the left page and display the search results.
There is also a text box and a button called "Refresh" on the right page. So that when users type a number, say "5", in the text box and click the "Refresh" button, the previously displayed results will be reduced to the number of rows according to the number in the text box.
Here is some snippets of my code:
[
//This is to display search results
if ($Msg == "NewUsr"
$SQLStmt = "Select datetime, nick, mobile from users order by datetime desc";
DisplayResults($SQLStmt);}
if ($Msg == "AllUsr"
$SQLStmt = "Select nick, mobile, datetime from users order by nick asc";
DisplayResults($SQLStmt); }
//This means to refresh the results, the text box for usr
//to input number is named as "txtNumber".
//The code is:
if($txtNumber != ""
$SQLStmt.= " limit 0, ".$txtNumber;
DisplayResults($SQLStmt); }
]
I intend to append clause "limit 0, '$txtNumber' " to the end of the SQL Stmt which is lastly executed. However, that SQL Stmt seems don't remain after executing. So I really want a some kind of global variable which can hold the value of that SQLStmt.
I tried defining the variable SQLStmt at the beginning of PHP script. I also tried defining a variable named 'G_SQLStmt' at the beginning and passed the value of SQLStmt to it. Here is how I do it:
[
if ($Msg == "RecentMsg"
$SQLStmt = "Select sender, mobile, datetime, messages from mo_messages order by datetime desc";
$G_SQLStmt = "Select sender, mobile, datetime, messages from mo_messages order by datetime desc";
DisplayResults($SQLStmt);}
]
However, neither of them work. Can someone help me on this?
BTW, the 'txtNumber' text box and 'Refresh' button are in a form called 'frmRefresh' on the right page. So the value of 'txtNumber' is passed to the right page itself and process accordingly.