Commit 003ad8a5 authored by rama chandra's avatar rama chandra
Browse files

Update view.php

parent a9aaf385
......@@ -2,8 +2,8 @@
$query = "SELECT * from bloo where id='".$id."'";
$query = "SELECT * from bloo ";
$result = mysqli_query($con, $query) or die ( mysqli_error());
$row = mysqli_fetch_assoc($result);
......@@ -16,41 +16,23 @@ $row = mysqli_fetch_assoc($result);
<div class="form">
<p><a href="dashboard.php">Dashboard</a> | <a href="insert.php">Insert New Record</a> | <a href="logout.php">Logout</a></p>
<h1>Update Record</h1>
<p><a href="index.php">Home</a> | <a href="insert.php">Insert New Record</a> | <a href="logout.php">Logout</a></p>
<h2>View Records</h2>
<table width="100%" border="1" style="border-collapse:collapse;">
<tr><th><strong>S.No</strong></th><th><strong>Name</strong></th><th><strong>Blood Group</strong></th><th><strong>Age</strong></th><th><strong>Last donated</strong></th><th><strong>Mobile No</strong></th><th><strong>City</strong></th><th><strong>Edit</strong></th><th><strong>Delete</strong></th></tr>
$status = "";
if(isset($_POST['new']) && $_POST['new']==1)
$uname =$_REQUEST['uname'];
$age =$_REQUEST['age'];
$dd =$_REQUEST['dd'];
$update="update bloo set uname='".$uname."', blood='".$blood."', age='".$age."', dd='".$dd."',mobile='".$mobile."',city='".$city."' where id='".$id."'";
$result1= mysqli_query($con, $update) or die ( mysqli_error());
$status = "Record Updated Successfully. </br></br><a href='view.php'>View Updated Record</a>";
echo '<p style="color:#FF0000;">'.$status.'</p>';
}else {
<form name="form" method="post" action="">
<input type="hidden" name="new" value="1" />
<input name="id" type="hidden" value="<?php echo $row['id'];?>" />
<p><input type="text" name="uname" placeholder="Enter Name" required value="<?php echo $row['uname'];?>" /></p>
<p><input type="text" name="blood" placeholder="Enter BLood Group" required value="<?php echo $row['blood'];?>" /></p>
<p><input type="text" name="age" placeholder="Enter Age" required value="<?php echo $row['age'];?>" /></p>
<p><input type="text" name="dd" placeholder="Enter Last donated" required value="<?php echo $row['dd'];?>" /></p>
<p><input type="text" name="mobile" placeholder="Enter Mobile No" required value="<?php echo $row['mobile'];?>" /></p>
<p><input type="text" name="city" placeholder="Enter City" required value="<?php echo $row['city'];?>" /></p>
<p><input name="submit" type="submit" value="Update" /></p>
<?php } ?>
$sel_query="Select * from bloo ORDER BY id desc;";
$result = mysqli_query($con,$sel_query);
while($row = mysqli_fetch_assoc($result)) { ?>
<tr><td align="center"><?php echo $count; ?></td><td align="center"><?php echo $row["uname"]; ?></td><td align="center"><?php echo $row["blood"]; ?></td><td align="center"><?php echo $row["age"]; ?></td><td align="center"><?php echo $row["dd"]; ?></td><td align="center"><?php echo $row["mobile"]; ?></td><td align="center"><?php echo $row["city"]; ?></td><td align="center"><a href="edit.php?id=<?php echo $row["id"]; ?>">Edit</a></td><td align="center"><a href="delete.php?id=<?php echo $row["id"]; ?>">Delete</a></td></tr>
<?php $count++; } ?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment