Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n.manasa #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions connect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
$conn=mysqli_connect("localhost","root","","tables");
if(!$conn){
die("connection failed: " .mysqli_connect_error());
}
else
echo "connected";
?>
11 changes: 11 additions & 0 deletions delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php include'connect.php';
$sql = "DELETE FROM details WHERE email = '[email protected]'";
if($conn->query($sql) === TRUE)
{
echo "record deleted successfully";
}
else{
echo"error deleting record: " . $conn->error;
}
$conn->close();
?>
28 changes: 28 additions & 0 deletions insert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "tables";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error());
}

$sql = "INSERT INTO details (name,phone,email)
VALUES ('John','12','[email protected]');";
$sql .= "INSERT INTO details (name,phone,email)
VALUES ('Mary','11','[email protected]');";
$sql .= "INSERT INTO details (name,phone,email)
VALUES ('Julie','13','[email protected]');";

if ($conn->multi_query($sql) == TRUE) {
echo "New records created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
38 changes: 38 additions & 0 deletions s2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "tables";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error());
}

$sql = "SELECT name, phone, email FROM details";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "name: " . $row["name"]. " - phone: " . $row["phone"]. " " . $row["email"]. "<br>";
}
} else {
echo "0 results";
}

$sql = "SELECT name, phone, email FROM details WHERE name='Mary' ";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "name: " . $row["name"]. " - phone: " . $row["phone"]. " " . $row["email"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
20 changes: 20 additions & 0 deletions web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php session_start();?>
<html>
<head>
<title>WEBPAGE</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<h2>Insert</h2><br/>
<a href="insert.php"><button type="submit" class="btn btn-success">INSERT</button></a><br/><br/>
<h2>Select</h2><br/>
<a href="s2.php"><button type="submit" class="btn btn-success">SELECT</button></a><br/><br/>
<h2>Delete</h2><br/>
<a href="delete.php"><button type="submit" class="btn btn-success">DELETE</button></a><br/><br/>
</body>
</html>