possible or not?: how do I use a variable as a table name
Posted: Tue May 02, 2006 10:54 am
Jcart | Please use
Any help is greatly appreciated,
Brad
Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am trying to do the following....
pass in a table name, and use it in a select stmt....but it will nt work...is there a syntax error or is this just not possible...Code: Select all
$_table = $_GET["table"];
$_table = $_table . "_admin";
// LOGIN TO THE DATABASE
mysql_connect("localhost", "user", "pass") or die("Cannot connect to DB!");
mysql_select_db("trek") or die("Cannot select DB!");
// GET CLASS LIST
$sql = "SELECT langid FROM '$_table'";Brad
Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]