?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


C# Help

?
?Calling a function in php and passing a variable.
Author:?Lee?(---.in-addr.btopenworld.com)
Date:???07-04-03 06:32

Hi there peeps,
I am a beginner and have a question: i have a database with hotels listed per country. I have a function which i'd like to use for all countries. However each countries hotels will be listed on its seperate page.

So basically i have an .inc file which has the generic db query something like this:

function showHotel($whichCountry)
global $whichCountry;
{
blah blah blah dbquery WHERE country=$whichCountry.
}


// then i call the query like so on my page hotels_spain.php:
// es for spain
showHotel("es");
?>


This should then translate to WHERE country=es.
However the variable whichCountry is always empty when it's called. Any ideas, i know its something simple but can remember how ;-0
Thanx
Lee

?Re: Calling a function in php and passing a variable.
Author:??(---.37-151.net24.it)
Date:???07-04-03 11:09

Hi
Why do you use "global $whichCountry;"?
The variable $whichCountry used in the query is the parameter of the function showHotel, not the global variable $whichCountry.

I hope this help you.
Bye
Nando

Go to Top??|??Go to Topic??|??Threaded View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??

Provided By
Phorum