Posts

Style with CSS File

  #main-title {     text-align : center ;     background-color : #333 ;     color : #fff ;     padding : 20px ;     letter-spacing : 2px ;     font-weight : 500 ; } .box1 h2 {     float : left ; } .box1 button {     float : right ; } .container {     margin-top : 50px ; } h6 {     text-align : center ;     color : red ; }

Home File in PHP

  <! DOCTYPE html > < html lang = "en" > < head >     < meta charset = "UTF-8" >     < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > </ head > < body >     < h1 > Hello from home.php </ h1 > </ body > </ html >

Delete data in database File in PHP

  <?php include ( "dbconn.php" ); if ( isset ( $_GET [ "id" ])) {     $idnew = $_GET [ "id" ]; } $sql = " DELETE FROM students WHERE id = ' $idnew ' " ; if ( $conn -> query ( $sql ) == TRUE ) {     header ( "location:index.php?delete_msg=YOU HAVE SUCCESSFULLY DELETED DATA" ); } else {     die ( "Query Failed : " . $conn -> error );     echo "Error : " . $sql . "<br>" . $conn -> error ; } $conn -> close ();

Update data in database File in PHP

  <?php include ( "header.php" ); include ( "dbconn.php" ); ? > <?php if ( isset ( $_GET [ "id" ])) {     $id = $_GET [ "id" ];     $sql = " SELECT * FROM students WHERE id = ' $id ' " ;     $result = $conn -> query ( $sql );     if ( $result -> num_rows > 0 ) {         $row = $result -> fetch_assoc ();         print_r ( $row );     } else {         echo "No Record Found<br>" ;     }     $conn -> close (); } ? > <?php if ( isset ( $_POST [ "update_students" ])) {     if ( isset ( $_GET [ "id_new" ])) {         $idnew = $_GET [ "id_new" ];     }     $fname = $_POST [ "f_name" ];     $lname = $_POST [ "l_name" ];     $age = $_POST [ "age" ];     $sql2 = " UPDATE students SET first_name = ' $fname ', last_name = ' $lname...

Insert data in database File in PHP

  <?php include ( "dbconn.php" ); if ( isset ( $_POST [ "add_students" ])) {     $fname = $_POST [ "f_name" ];     $lname = $_POST [ "l_name" ];     $age = $_POST [ "age" ];     if ( $fname == "" || empty ( $fname )) {         header ( "location:index.php?message=YOU NEED TO FILL IN THE FIRST NAME" );     } else {         $sql = " INSERT INTO students(first_name, last_name, age) VALUES (' $fname ', ' $lname ', ' $age ') " ;         if ( $conn -> query ( $sql ) === TRUE ) {             header ( "location:index.php?insert_msg=YOUR DATA HAS BEEN ADDED SUCCESSFULLY" );         } else {             die ( "Query Failed  : " . $conn -> error ) . "<br>" ;             echo "Error : " . $sql . "<br>" . $conn -> error ;  ...

Index File in PHP

  <?php include ( "header.php" ); include ( "dbconn.php" ); ? > < div class = "box1" >     < h2 > ALL STUDENTS </ h2 >     < button class = "btn btn-primary" data-toggle = "modal" data-target = "#exampleModal" > ADD STUDENTS </ button > </ div > < table class = "table table-hover table-bordered table-striped" >     < thead >         < tr >             < th > ID </ th >             < th > First_Name </ th >             < th > Last_Name </ th >             < th > Age </ th >             < th > Update </ th >             < th > Delete </ th >         </ tr >     </ thead >   ...

Footer File in PHP

  </ div >         <!-- jQuery library --> < script src = "https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.slim.min.js" ></ script > <!-- Popper JS --> < script src = "https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" ></ script > <!-- Latest compiled JavaScript --> < script src = "https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" ></ script >     </ body > </ html >