Jump to content

Help with adding checkbox into mysql


snowymasta

Recommended Posts

Hey Guys,

 

I'm really struggling to find whats wrong with this code. The form before submit has several checkboxes as part of an array which is below

     
<?php
$conn = new mysqli($servername, $username, $password, $dbname);    
$sql = "SELECT * FROM `engineers`";
$result = $conn->query($sql);
        
while($row = mysqli_fetch_assoc($result)) {
    
    $endid = $row["endid"];
    $resource_name = $row["resource_name"];
    $resource_email = $row["resource_email"];
    $picture = $row["picture"];
    
    echo "<label>".$resource_name."</label><input type='checkbox'  class='form-control' name='engineers[]' value=''.$endid.''><br>";
    
         }
    
        ?>

The next page then goes to this and I get the error "Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /homepages/39/d837976904/htdocs/Scheduler/add_job3.php:10 Stack trace: #0 {main} thrown in /homepages/39/d837976904/htdocs/Scheduler/add_job3.php on line 10"

<?php
// Initialize the session
session_start();

$process = $_GET["process"];

include "Includes/config.php";
include "Includes/db.php";


mysql_connect($servername, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$checkBox = implode(',', $_POST['engineers']);

if(isset($_POST['submit']))
{       
    $query1="INSERT INTO job_activity (endid) VALUES ('" . $checkBox . "')";     

    mysql_query($query1) or die (mysql_error() );

    echo "Complete";

}

?>
 

Can anyone help with the code please :(

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.