Reputation: 343
I have a combined INSERT and SELECT in my php code and I really need it to add a few variables instead of what's in the database.
Original Code:
$result2 = mysqli_query($res, "INSERT INTO editor (track,userid,title,page_title,background,video,main_heading,subtext1,subtext2,subtext3,subtext4,btncolor,btntcolor,btntsize,htsize,htcolor,onesize,onecolor,twosize,twocolor,threesize,threecolor,addvideo,formr,gotourl,visitors,precount,joincount,archive,popup) SELECT track,userid,title,page_title,background,video,main_heading,subtext1,subtext2,subtext3,subtext4,btncolor,btntcolor,btntsize,htsize,htcolor,onesize,onecolor,twosize,twocolor,threesize,threecolor,addvideo,formr,gotourl,visitors,precount,joincount,archive,popup FROM editor WHERE id='$lp' AND userid='$uplineid'");
Instead of it selecting the userid
from the table, I would like it to use the variable $myid
and instead of track
I would like to use $track
and for visitors
I would like to use $visitors
So it would insert those variables with the rest of the database information.
I have tried everything and keep getting errors. Any help would be great.
Upvotes: 0
Views: 13
Reputation: 178
You can use query like below..
1-$qryIns = "insert into tab1 (c1, c2, c3) select c1, '" . $_REQUEST['data'] . "', c3 from tab2;";
2-$qryIns = "insert into tab1 (c1, c2, c3) select c1, '" . $_REQUEST['data'] . "' c2, c3 from tab2;";
Upvotes: 1