How can i run multiple queries on my code in php?

Mira BeeCalifonia

I have tried this code, but i'm getting errors

$sql[0] = "INSERT INTO classtb
                    (classname, duration, classdate, cost, location, 
                    instructor, client, subclient, courseware, note)  
            VALUES('$classname', '$duration', '$classdate', '$cost', 
                    '$loc2name', '$instructor','$client','$subclient', 
                    '$courseware', '$note')";
$sql[1] = "INSERT INTO locationtb(slocation, address, note)  
            VALUES('$loc2name', '$loc2address', '$loc2note')";
//etc...

foreach ($sql as $x) {
    if ($db->query($sql[$x])) {
         echo "worked";
    else{
         echo "Didn't work";
    }
}

I'm getting double error as both are not loading into the tables

Simon K

You need to use the value of the $sql array inside your loop.

Change the following...

$db->query($sql[$x])

To...

$db->query($x)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I run multiple raw queries with sequelize in MySql?

How can I run a code for multiple JButtons?

How can I import multiple mysql queries exported as a text with php?

Python when I run my code, how can I split my screen into parts and have them print out multiple things

How do I run two queries in my JSP file. Following is my code

How to run multiple queries in one php page?

How can I prevent multiple ajax queries from being run on "prev" button being clicked multiple times

how can i run my scala code coverage fully

How can I run my code upon class load?

How can I run my python code as a script

How can I improve my code, and why does it not run?

How can I streamline my VBA code to run faster?

What is my error, how can I make this code run correctly?

How can I run my code during waiting user input

How can i run all my code in one function

How can I put this php code(if condition) in my html code?

How can I run multiple lines of code in R

How can I streamline code to run multiple pipelines in machine learning?

How can I add a short PHP code into my PHP file

I can't find a sqlsrv code to execute multiple SQL queries,on php, that afect each other

How can I run multiple queries on load of functional component using UseEffect and get result in render method?

How can I maintain multiple open queries?

How can i order by for multiple queries combination

How can I separate my typescript code into multiple files?

How can I create Multiple selected for my recyclerview code?

In VS Code, how can I break my project into multiple files?

How can I run separate PHP code on a domain with WordPress installed?

How can I run PHP code within a Java application?

How can I break up my code so Xcode will let my run my App | SwiftUI