Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername="localhost";
- $username="root";
- $password="";
- $conn=mysqli_connect($servername, $username, $password,"ajax" );
- extract($_POST);
- if(isset($_POST['readrecord'])){
- $data = '<table class="table table-bordered table-striped">
- <tr>
- <th> No.</th>
- <th> First Name </th>
- <th> Last name </th>
- <th> Email Address</th>
- <th> Mobile Number </th>
- <th> Edit Action</th>
- <th> Delete Action</th>
- </tr>';
- $displayquery = "SELECT * FROM 'crud' ";
- $result=mysqli_query($conn,$displayquery);
- if(mysqli_num_rows($result) >0){
- $number=1;
- while ($row= mysqli_fetch_array($result)) {
- $data .='<tr>
- <td>'.$number.'</td>
- <td>'.$row['firstname'].'</td>
- <td>'.$row['lastname'].'</td>
- <td>'.$row['email'].'</td>
- <td>'.$row['mobile'].'</td>
- <td>
- <button onclick="GetUserDetailes('.$row['id'].')"
- class="btn sbtn-warning">Edit</button>
- </td>
- <td>
- <button onclick="DeleteUser('.$row['id'].')"
- class="btn btn-danger">Delete</button>
- </td>
- </tr>';
- $number++;
- }
- }
- $data .='</table>';
- echo $data;
- }
- if (isset($_POST['firstname']) && ($_POST['lastname']) &&
- ($_POST['email']) && ($_POST['mobile']) )
- {
- $query=" INSERT INTO `crud`( `firstname`, `lastname`, `email`, `mobile`)
- VALUES ('$firstname','$lastname','$email','$mobile')";
- mysqli_query($conn,$query);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement