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

anila sree #16

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
49 changes: 49 additions & 0 deletions ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<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>
<title>Retrieval</title>
</head>
<body>
<div class="container">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Phone</th>
<th>Email</th>
</tr>
</thead>
<?php
include 'connect.php';
$name = $_POST['name'];
if(empty($name))
$query =" SELECT * FROM datadetails ";
else
$query =" SELECT * FROM datadetails WHERE 'name' = '$name'";
$result = mysqli_query($con,$query);
$count = 0;
$arr=array();
while($row=mysqli_fetch_array($result))
{
$arr[]=$row;
$count++;
}
for($i=0;$i<$count;$i++)
{
echo "<tr>";
echo "<td>".$arr[$i]['name']."</td>";
echo "<td>".$arr[$i]['phone']."</td>";
echo "<td>".$arr[$i]['email']."</td>";
echo "</tr>";
}
mysqli_close($con);
?>
</table>
</div>
</body>
</html>
14 changes: 14 additions & 0 deletions connect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test1";

$conn = mysqli_connect($servername, $username, $password, $dbname);
if(!$conn)
{
die("Connection failed:" . mysqli_connect_error ());
}
else
echo "connected";
?>
14 changes: 14 additions & 0 deletions delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php include 'connect.php';
$sql = "DELETE FROM details WHERE email = '[email protected]'";

if ($conn->query($sql) == TRUE)
{
echo "RECORD DELETED";
}
else
{
echo "error :" . $conn->error;
}

$conn->close();
?>
30 changes: 30 additions & 0 deletions insert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php include 'connect.php';
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test1";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if(!$conn)
{
die("connection failed: " . mysqli_connect_error());
}
else
echo "connected";

$sql = "INSERT INTO details (name,phone,email)
VALUES ('ANILA', '123456789', '[email protected]');";
$sql .= "INSERT INTO details (name,phone,email)
VALUES ('Abhi', '123987789', '[email protected]');";
$sql .= "INSERT INTO details (name,phone,email)
VALUES ('ram', '123456456', '[email protected]');";

if (mysqli_multi_query($conn, $sql))
{
echo "INSERTED SUCCESSFULLY";
}
else
{
echo "error:" . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>
69 changes: 69 additions & 0 deletions select.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php include 'connect.php';
$sql = "SELECT * FROM details";
$result = $conn->query($sql);

if ($result->num_rows > 0)
{
echo "<h1>Database</h1>";
echo "<table>";
echo "<tr>";
echo "<th>Name</th>";
echo "<th>phone</th>";
echo "<th>email</th>";
echo "</tr>";
while($row = $result->fetch_assoc())
{
echo "<tr>";
echo "<td>";
echo $row["name"];

echo "<td>";
echo $row["phone"];

echo "<td>";
echo $row["email"];
echo "</td>";

}
echo "</table>";
}
else
{
echo "No results";
}

$sql1 = "SELECT * FROM details WHERE name = 'Abhi' ";
$res1 = $conn->query($sql1);


if ($res1->num_rows > 0)
{


echo "<h1>Database</h1>";
echo "<table>";
echo "<tr>";
echo "<th>Name</th>";
echo "<th>phone</th>";
echo "<th>email</th>";
echo "</tr>";
while($row = $res1->fetch_assoc())
{
echo "<tr>";
echo "<td>";
echo $row["name"];

echo "<td>";
echo $row["phone"];

echo "<td>";
echo $row["email"];
echo "</td>";

}
echo "</table>";
}


$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="select.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>