Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con= mysqli_connect ("localhost","root","","");
- if (mysqli_connect_errno())
- {
- echo "Failure to connect Mysql".mysqli_connect_error();
- }
- mysqli_select_db ($con, "vijay_rami");
- if($_POST["submit"] == "add")
- {
- $quli = $_POST['quli'];
- if(is_array($_POST['quli'])){
- $a = serialize($_REQUEST['quli']);
- $sql= "INSERT INTO studentdata (firstname,lastname,gender,qulification,address,city,country) VALUES ('".$_POST['fname']."','".$_POST['lname']."','".$_POST['gr']."','$a','".$_POST['address']."','".$_POST['city']."','".$_POST['country']."')";
- }
- $result=mysqli_query($con,$sql);
- if ($result)
- echo "Data Inserted Successfully";
- else
- echo "Error in inserting Data";
- }
- if ($_GET["action"] == "delete")
- {
- $result = mysqli_query ($con,"DELETE FROM studentdata WHERE id='".$_GET['id']."'");
- if ($result)
- echo "Data Deleted Successfully";
- else
- echo "Error In Deleting Data";
- }
- if ($_POST['submit'] == "edit")
- {
- $quli = $_POST['quli'];
- if(is_array($quli)){
- $b = serialize($quli);
- $sql= "UPDATE studentdata SET firstname='".$_POST['fname']."',lastname='".$_POST['lname']."', gender='".$_POST["gr"]."',qulification='$b',address='".$_POST['address']."',city='".$_POST['city']."',country='".$_POST['country']."' WHERE id='".$_POST['id']."'";
- }
- $result = mysqli_query ($con,$sql);
- if ($result)
- echo "Succesfully updated into database";
- else
- echo "Error while updating into database!!!";
- }
- $result1= mysqli_query ($con,"SELECT * FROM studentdata ORDER BY id");
- ?>
- <table border='1'>
- <tr>
- <th>Id</th>
- <th>First name</th>
- <th>Last name</th>
- <th>Gender</th>
- <th>Qualification</th>
- <th>Address</th>
- <th>City</th>
- <th>Country</th>
- <th>edit</th>
- <th>delete</th>
- </tr>
- <?while($student= mysqli_fetch_array ($result1))
- {?>
- <tr>
- <td><?=$student['id']?></td>
- <td><?=$student['firstname']?></td>
- <td><?=$student['lastname']?></td>
- <td><?=$student['gender']?></td>
- <td><?
- $qulif = $student['qulification'];
- $myquls = unserialize($qulif);
- for($i=0; $i < count($myquls); $i++){
- echo $myquls[$i].',';
- }
- ?></td>
- <td><?=$student['address']?></td>
- <td><?=$student['city']?></td>
- <td><?=$student['country']?></td>
- <td><a href="edit.php?action=edit&id=<?=$student['id']?>">Edit</a></td>
- <td><a href="form.php?action=delete&id=<?=$student['id']?>">Delete</a></td>
- </tr>
- <?}?>
- </table>
- <a href="dbform.php">Click To Add</a>
- <? mysqli_close($con);?>
Advertisement
Add Comment
Please, Sign In to add comment