PHP : Using a variable to hold a table name, and using that variable in queries [duplicate] PHP : Using a variable to hold a table name, and using that variable in queries [duplicate] database database

PHP : Using a variable to hold a table name, and using that variable in queries [duplicate]


<?php$mysql_tb = 'tb_registered_users';$query = "SELECT `stud_no` FROM `{$mysql_tb}` WHERE `stud_no`='$studno'";$query = "INSERT INTO `{$mysql_tb}` VALUES ('".$studno."','".$firstname."','".$lastname."')";


$query = "INSERT INTO `" . $mysql_tb . "`VALUES ('".$studno."','".$firstname."','".$lastname."')";


$mysql_tb = 'tb_registered_users';$query = "SELECT `stud_no` FROM `".$mysql_tb."` WHERE `stud_no`='$studno'";