SELECT * FROM $variable as table name problem
Im trying to load a page with a table from my mysql database.
Im using a dynamic variable as the table name instead of a static table name( this is obviously giving the mysql_error)
Ive tried with and without single quotes and all sorts of ways of SELECTing from a variable but no luck. I understand that theres a different way to handle it if the table name is dynamic but im not sure.
$classcode = mysql_real_escape_string($_POST['classcode']);
$q = "SELECT * FROM `$classcode`";
$query = mysql_query($q) or die(mysql_error);
Unfortunately, because each of these tables is created dynamically, I cant select information from one with a static name, as each name will be generated seperately, etc, hoepfully you see the dilemma.
Any help at all is greatly appreciated. Thanks in advance ;)