I want to know how to create and call a function. Here's what I have. I have a PHP block of at the very begining of the page even before the <html> and then at the <body> tag, I declare the function as: function myfunction(){
do my stuff here including echo file download link
}
Then on the PHP block of code that's before <html>, I have myfunction() as my function calling.
Can anyone tell me if what I'm doing is right? If not, will you show me how?
Many thanks in advance!
ljCharlie
How to declare and call function?
Moderator: General Moderators
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
Heres' what I want it.
When do this, the page would not display anything. Howver, if I combined both PHP block of code into one inside the body tag then it works just fine. Suggestions are much appreciated.
ljCharlie
Code: Select all
<?PHP
do my database connection and testing here
if ($btnDate =="Extract Date"){
queryByDate();
}
?>
<html>
<head></head>
<body>
<?PHP
function queryByDate(){
echo my links here
}
?>
</body>
</html>ljCharlie
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
Oh, by the way, I have one more question.
In the <body> tag, I have the function echo something onto the page, however, since the function was called before the <html> tag, the echo is being displayed before the <html> and not the in the <body> tag where I put the function in. How do i solve this problem?
ljCharlie
In the <body> tag, I have the function echo something onto the page, however, since the function was called before the <html> tag, the echo is being displayed before the <html> and not the in the <body> tag where I put the function in. How do i solve this problem?
ljCharlie