hello forum
im trying to insert record in different table using single query (on the base of class, class name and tables name are same)and wants to insert record in 1 table at 1 time is it possibol to select the table name through class here is the code but its is nt working

$dbhandle = mysql_connect('localhost', 'root', '');

        if ($dbhandle == false)
        {
                 die  ("Unable to connect to MySQL Database<br>");
        }



if(!($db = mysql_select_db('registration'))){
echo "byeeeeeeeeeeeeeeeeeeeeeeeeeeee";


}



$tab=$_REQUEST['cls'];
$ser=$_REQUEST[roll];
$sb1=$_REQUEST['sub1'];
$sb2=$_REQUEST['sub2'];
$sb3=$_REQUEST['sub3'];
$sb4=$_REQUEST['sub4'];
$sb5=$_REQUEST['sub5'];
$sb6=$_REQUEST['sub6'];
$tot=$_REQUEST['total'];
$obt=$_REQUEST['obtain'];
$percent=$_REQUEST['percent'];
$remark=$_REQUEST['remark'];
$q2="INSERT INTO".$tab."(ser,sub1,sub2,sub3,sub4,sub5,sub6,total,obtain,percentage,remarks)values(".$ser.",'".$sb1."','".$sb2."','".$sb3."','".$sb4."','".$sb5."','".$sb6."','".$tot."','".$obt."','".$percent."','".$remark."')";
//$result = mysql_query($q2);
echo $tab;
if(!($result = mysql_query($q2))){
echo "whoooooooooooooooooooooops";
 }
 else
 {
		
echo "<br>";

echo $ser;
echo"hiiiiiiiiiiiiiii";
echo $tab;
}


?>

the query is wrong. there are no spaces between INTO and your tablename, therefor the query will return an error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.