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
<?php
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
pass variables to a db function
Moderator: General Moderators
-
CyberSpatium
- Forum Newbie
- Posts: 21
- Joined: Thu Mar 20, 2003 12:23 pm
- Contact:
Remove this from inside your function:
Using global inside your function invalidates whatever $whichCountry is set to, registers it as a global variable, and sets it to NULL. That is why $whichCounty is not being passed to your function.
Cyber
Code: Select all
global $whichCountry;Cyber