Re: Passing mysql table names to php functions?
- From: "J.O. Aho" <user@xxxxxxxxxxx>
- Date: Tue, 27 Feb 2007 19:45:12 +0100
kennthompson@xxxxxxxxx wrote:
No. That won't work either. I need to add one more thing. To make the
stable version work I had to identify the old table name as global. I
think this looks simpler than it really is. I thought a simple
variable name could be passed as a table name, but there must be some
mysql code that allows it.
Can you post the whole code you actually are using?
for a code like
function functionname($tablename) {
$query="SELECT * FROM ".$tablename;
$result=mysql_query($query);
while($row=mysql_fetch_array($result)) {
/* do what you do */
}
}
will work fine, as long as the variable you use as an argument for the function does have a value and that there is a such table in your database.
$thistable="a_table";
functionname($thistable);
--
//Aho
.
- Follow-Ups:
- Re: Passing mysql table names to php functions?
- From: kennthompson
- Re: Passing mysql table names to php functions?
- References:
- Passing mysql table names to php functions?
- From: kennthompson
- Re: Passing mysql table names to php functions?
- From: Jose da Silva
- Re: Passing mysql table names to php functions?
- From: kennthompson
- Re: Passing mysql table names to php functions?
- From: J.O. Aho
- Re: Passing mysql table names to php functions?
- From: kennthompson
- Passing mysql table names to php functions?
- Prev by Date: Re: testing php on my home computer
- Next by Date: Re: Sessions in different versions of PHP
- Previous by thread: Re: Passing mysql table names to php functions?
- Next by thread: Re: Passing mysql table names to php functions?
- Index(es):