Virajsinh

ViewRecord.php

Apr 2nd, 2018
64
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     echo
  4.     "
  5.     <center>
  6.     <table>
  7.         <tr>
  8.             <td> <a href='Form.html' style='underline'>Insert Record</a> </td>
  9.             <td> <a href='UpdateRecord.html'>Update Record</a>
  10.             <td> <a href='DeleteRecord.html'>Delete Record</a>
  11.         </tr>
  12.     </table>   
  13.     ";
  14.    
  15.    
  16.     $con = mysqli_connect("localhost","root","","mscit");
  17.    
  18.     if(!$con)
  19.     {
  20.         die("Error".mysqli_error());
  21.     }
  22.     else
  23.     {
  24.         //none
  25.     }
  26.    
  27.     $dbselect ="select * from login";
  28.    
  29.     $result = mysqli_query($con, $dbselect);
  30.    
  31.     if (mysqli_num_rows($result) > 0)
  32.     {
  33.         echo "<table border='0' align='center'>";
  34.        
  35.         echo "<tr>
  36.                 <td> Username </td>
  37.                 <td> Password </td>
  38.                 <td> Gender </td>
  39.                 <td> City </td>
  40.                 <td> Email </td>
  41.                 <td> Age </td>
  42.                 <td> Delete </td>
  43.               </tr>";
  44.         // output data of each row
  45.         while($row = mysqli_fetch_assoc($result))
  46.         {
  47.             echo "<tr>";
  48.             echo "<td>".$row["username"]."</td>";
  49.             echo "<td>".$row["password"]."</td>";
  50.             if($row["gender"]=="M")
  51.                 echo "<td>Male</td>";
  52.             else
  53.                 echo "<td>Female</td>";
  54.            
  55.             echo "<td>".$row["city"]."</td>";
  56.             echo "<td>".$row["email"]."</td>";
  57.             echo "<td>".$row["age"]."</td>";
  58.             echo "<td><a href='delete.php?un=".$row["username"]."'>Delete</a></td>";
  59.             echo "</tr>";
  60.            
  61.             //echo "<br>Usernaem : ".$row["username"]. " Password : ".$row["password"]." Age : ".$row["age"]. "<br>";
  62.         }
  63.         echo "</table>";
  64.     }
  65.     else
  66.     {
  67.         echo "0 results";
  68.     }
  69.    
  70.     echo "  </center>";
  71. ?>
RAW Paste Data