In: Computer Science
Create a new SQL table in your phpMyAdmin account that collects the following fields (columns) -
1) The name of a medicine, sanitizer, or tip/trick for protecting yourself against transmission or fight the disease - STRING
2) The amount of money the item costs - NUMBER
3) The UPC code of the item - NUMBER
4) Manufacturing country of the item - STRING
Connect to the SQL database with your HTML code, and make sure to show the results of ALL columns show! -
Create a form where the user can insert their items into the 4 columns mentioned above -
Build the HTML site with at least 5 pictures and a few paragraphs explaining your creativity (and how important it is to be safe this flu season!) - make sure to use proper APA guidelines for your in-text citations and a bibliography section! -
SQL Code :
CREATE TABLE table1 (
Medicine_name varchar(255),
Amount int,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
Html code : //I have written basic html code for creating the from. Hope you can insert pictures and write relevant text.
<!DOCTYPE html>
<html>
<head>
<title>Form site</title>
</head>
<body>
<form method="post" action="connect.php">
Cure : <input type="text" name="Medicine"><br><br>
Cost : <input type="number " name="Cost"><br><br>
UPC : <input type="number " name="UPC"><br><br>
Country : <input type="text" name="Country"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Php code:
<?php
$cure = filter_input(INPUT_POST, 'cure');
$cost = filter_input(INPUT_POST, 'cost');
if (!empty($cure)){
if (!empty($cost)){
$host = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "my_db";
// Create connection
$conn = new mysqli ($host, $dbcure, $dbcost, $dbname);
if (mysqli_connect_error()){
die('Connect Error ('. mysqli_connect_errno() .') '
. mysqli_connect_error());
}
else{
$sql = "INSERT INTO account (cure, cost)
values ('$cure','$cost')";
if ($conn->query($sql)){
echo "New record is inserted sucessfully";
}
else{
echo "Error: ". $sql ."
". $conn->error;
}
$conn->close();
}
}
else{
echo "Values should not be empty";
die();
}
}
else{
echo "Values should not be empty";
die();
}
?>