Created
April 16, 2020 06:37
-
-
Save biplab3/3f9466dab9a342853796ab732edc6d42 to your computer and use it in GitHub Desktop.
PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('connect.php'); | |
if(isset($_POST['save'])){ | |
$company_name = $_POST['company_name']; | |
$brand_name = $_POST['brand_name']; | |
//insert checkbox values | |
$cars = implode(',',$_POST['car_name']); | |
//insert data into database | |
$sql="INSERT INTO cars(company_name,brand_name,car_name)VALUES('$company_name','$brand_name','$cars')"; | |
$stmt=$con->prepare($sql); | |
$stmt->execute(); | |
echo '<div class="alert alert-success">Submitted Successfully</div>'; | |
//insertion complete | |
} | |
//get the cars | |
$stmt2 = $con->prepare("select * from cars"); | |
$stmt2->execute(); | |
$cars = $stmt2->fetchAll(PDO::FETCH_ASSOC); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment