Click here to Skip to main content
15,918,617 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to inserting multiple array values into db.

What I have tried:

PHP
        $sqlquery = $connect->query("SELECT * FROM student,finalresults WHERE finalresults.stid = student.userid");

        while ( $rows = $sqlquery->fetch_assoc() ) {

            $total = $rows["marks"];
            $average = $total/10;

           //takes two values here as array values
            $values[] = "( '{$rows['courseid']}', '{$rows['marks']}') ";

            //takes two values here as array values
            $wastan[] = "Total:$total,Average: $average";
        }

        for($x = 1; $x<=count($values); $x++){
//Here I force 10 subject to display together by unique student ID
            if(!(($i++) % 10)){

                print $values[$x];
                print "<hr>";

 } esle{ print $values[$x]; } }
Posted
Updated 22-Jun-17 12:51pm
v4

You should try this

foreach ($_POST['username'] as $username, $_POST['fname'] as $fname,$_POST['lname'] as $lname)
{
}
 
Share this answer
 
Quote:
I want to inserting multiple array values in PHP

You should think about describing the problem.

To have working code, the first step is to correct source code and remove syntax errors.
PHP
} else{ print $values[$x]; } }
 
Share this answer
 
Comments
divisiblebyzero 23-Jun-17 10:26am    
https://stackoverflow.com/questions/44695497/i-want-to-inserting-multiple-array-values-into-db?noredirect=1#comment76403227_44695497
Patrice T 23-Jun-17 10:33am    
And ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900