Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WIEW
- <?php
- require_once("./controller/controller.php");
- ?>
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8" />
- </head>
- <body>
- sprawdzanie liczb:<br />
- <table border='1' ><tr>
- <th> lp </th>
- <th> liczba 1</th>
- <th> liczba 2 </th>
- <th> Czy podzielna? </th>
- <?php $check->getCheck(); ?>
- </tr></table>
- </body>
- </html>
- MODEL
- <?php
- class Connect{
- private $host = "localhost";
- private $db = "matematyka";
- private $user = "root";
- private $password = "";
- public function setConnect($host, $db, $user, $password){
- $this->host = $host;
- $this->db = $db;
- $this->user = $user;
- $this->password = $password;
- }
- public function getConnect(){
- return $conn = new PDO('mysql:host='.$this->host.';dbname='.$this->db.'',$this->user,$this->password);
- }
- }
- class QueryDB extends Connect{
- private $result;
- public function setQueryDB($result, $obj){
- $this->result = $result;
- }
- public function getQueryDB(){
- $this->result = $this->getConnect()->query("SELECT * FROM liczby");
- return $this->obj = $this->result -> fetchAll(PDO::FETCH_OBJ);
- }
- }
- ?>
- TO TEN ZE ZDJECJA
- CONTROLER
- <?php
- require_once("./model/model.php");
- class Check extends QueryDB{
- public function getCheck(){
- $lp=1;
- foreach($this->getQueryDB() as $value){
- echo "<tr>";
- if($value->a % $value->b == 0){
- echo "<tr bgcolor ='green'>";
- echo "<td>".$lp." </td>";
- echo "<td>".$value->a." </td>";
- echo "<td>".$value->b. "</td>";
- if($value->a % 2 == 0 || $value->b % 2 == 0)
- echo "<td><b>TAK</b></td>";
- else
- echo "<td>TAK</td>";
- echo "</tr>";
- }else { echo "<tr bgcolor ='red'>";
- echo "<td >".$lp."</td>";
- echo "<td>".$value->a." </td>";
- echo "<td>".$value->b. "</td>";
- if($value->a % 2 == 0 || $value->b % 2 == 0)
- echo "<td><b>NIE</b></td>";
- else
- echo "<td>NIE</td>";
- echo "</tr>";
- }
- echo "</tr>";
- $lp++;
- }
- }
- }
- $check = new Check;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement