/exam7/crud/src/bitm/seip131181/semister/Semister.php
https://gitlab.com/mehedi-xion/web_apps_php_26 · PHP · 164 lines · 86 code · 75 blank · 3 comment · 17 complexity · 07e2b79664be1a0699fa8b183ff1f745 MD5 · raw file
- <?php
- namespace SemisterApp\bitm\seip131181\mobile ;
- /**
- * class for Semister App
- */
- class Semister
- {
- public $id = '';
- public $name = '';
- public $semister = '';
- public $offer = '';
- public $cost = '';
- public $waiver = '';
- public $total = '';
- public $data = '';
-
- function __construct()
- {
- session_start();
- $sql_conn = mysql_connect('localhost', 'root', '') or die("ups! not connect to database");
- mysql_select_db('web_apps_php_26') or die("Wrong Database name");
- }
- public function prepare($data = ''){
- if(array_key_exists('fname', $data)){
- $this->name = $data['fname'];
- }
- if(array_key_exists('semister', $data)){
- $this->semister = $data['semister'];
- }
- if(array_key_exists('offer', $data)){
- $this->offer = $data['offer'];
- }
- if(array_key_exists('id', $data)){
- $this->id = $data['id'];
- }
- if($this->semister == '1st Semister'){ $this->cost = 8000;}
- if($this->semister == '2nd Semister'){ $this->cost = 12000;}
- if($this->semister == '3rd Semister'){ $this->cost = 16000;}
- if($this->offer == "offered"){$this->waiver = ($this->cost * 10)/100;}else{
- $this->offer = "Not Offered";
- $this->waiver = 0;
- }
- if ($this->offer == "Not Offered") {
- $this->waiver = 0;
- }
- $this->total = ($this->cost - $this->waiver);
-
- return $this ;
- }// prepare \\
- public function store(){
- $query = "INSERT INTO `web_apps_php_26`.`semister` (`id`, `name`, `semister`, `offer`, `cost`, `waiver`, `total`, `unique_id`) VALUES (NULL, '$this->name', '$this->semister', '$this->offer', '$this->cost', '$this->waiver', '$this->total','".uniqid()."')";
- if(mysql_query($query)){
- $_SESSION['Message'] = " Data Added Succesfully ";
- }
- header("location:creat.php");
- } // store \\
- public function index(){
- $query = "SELECT * FROM `semister` ";
- $result = mysql_query($query);
- while($row = mysql_fetch_assoc($result)){
- $this->data[] = $row;
- }
- return $this->data;
- } // index \\
- public function show(){
- $query = "SELECT * FROM `semister` WHERE unique_id = '".$this->id."' ";
-
- $result = mysql_query($query);
- $row = mysql_fetch_assoc($result);
- return $row;
- } // show \\
- public function update(){
- $query = "UPDATE `web_apps_php_26`.`semister` SET `name` = '$this->name', `semister` = '$this->semister', `offer` = '$this->offer', `cost` = '$this->cost', `waiver` = '$this->waiver', `total` = '$this->total' WHERE `semister`.`unique_id` = '".$this->id."'";
- if($result = mysql_query($query)){
- $_SESSION['UpdtMsg'] = "Data Updated Successfully";
- }
- header("location:edit.php?id=$this->id");
- }// update \\
- public function delete(){
- $query = "DELETE FROM `web_apps_php_26`.`semister` WHERE `semister`.unique_id = '".$this->id."' ";
-
- if($result = mysql_query($query)){
- $_SESSION['UpdtMsg'] = "Data Updated Successfully";
- }
- header("location:edit.php?id=$this->id");
-
- } // Delete\\
- }// class \\
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <!-- Latest compiled and minified CSS -->
- <link rel="stylesheet" href="../../../../style.css">