Reply to Re: Passing mysql table names to php functions?

Your name:

Reply:


Posted by J.O. Aho on 02/27/07 18:45

kennthompson@gmail.com 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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация