Thanks to you both guys. As for reading the manual - I have 4 in front of me
and couldn't find the answer to my problem. Some things you do find, some
things you dont, and typically the thing you don't find are usually staring
you in the face! As for learning all this PHY and MySQL stuff, it aint so
much reading the manual cover to cover, but dipping in and out at the
sections you need. I'll underatdn it all one day.... I Hope!

Thanks again to you both!
Noel


"Zac Hester" <newsplanetzac.net> wrote in message
news:3f1c7b1b$1news.enetis.net...
> "Noel Ferguson" <fergusonconsulting.club24.co.uk> wrote in message
> news:bfh7sn$jm6$2titan.btinternet.com...
> > Rather than state a table name in an MySQL query can someone pleasse
tell
> me
> > whether I can use a variable to define the table name and if so what is
> the
> > correct statement e.g.
> >
> > instead of
> >
> > $sql = "SELECT * FROM uk WHERE Feature_Classification='P' AND
FULL_NAME_ND
> > LIKE '$town'";
> >
> > have something like
> >
> > $sql = "SELECT * FROM $Primary_country WHERE Feature_Classification='P'
> AND
> > FULL_NAME_ND LIKE '$town'";
> >
> > Thanks
> > Noel Ferguson
>
> Hey Noel,
>
> Marcus answered your question perfectly, but I thought it might help you
to
> know that the query you send to the mysql_query() function is just a
string.
> It is absolutely no different than any other string you use in PHP. All
> string functions and properties work without any limitation. Therefore,
you
> can create the string using concatenation, regular expressions, loops, or
> whatever:
>
> $q = 'select * from some_table where';
> $criteria = array('lastname' => 'Johnson', 'firstname' => 'Bob', 'age' =>
> '35');
> foreach($criteria as $key => $val) {
> $q .= " $key = '$val' and ";
> }
> $q = substr($q, -5);
> mysql_query($q);
>
> I hate to say it so much, but if you had read the PHP manual, you'd know
all
> of this.
>
> HTH,
> Zac
>
>