SHOW:
|
|
- or go back to the newest paste.
| 1 | PLIK INDEX.PHP | |
| 2 | <?php | |
| 3 | include 'config/db.php'; | |
| 4 | include 'config/portal.php'; | |
| 5 | if(array_key_exists('view',$_GET)){
| |
| 6 | $views = $_GET['view']; | |
| 7 | } | |
| 8 | else {
| |
| 9 | $views = 'mems'; | |
| 10 | } | |
| 11 | $viewsFolder = 'views/' . $views . '.php'; | |
| 12 | if(file_exists($viewsFolder)){
| |
| 13 | ob_start(); | |
| 14 | include ($viewsFolder); | |
| 15 | $content = ob_get_contents(); | |
| 16 | ob_end_clean(); | |
| 17 | include ('layouts/main.php');
| |
| 18 | } | |
| 19 | else {
| |
| 20 | echo "404"; | |
| 21 | } | |
| 22 | ?> | |
| 23 | <---------------------------------------> | |
| 24 | ||
| 25 | ||
| 26 | PLIK mems.php | |
| 27 | ||
| 28 | <section id="mems"> | |
| 29 | <div class="container"> | |
| 30 | <div class="row"> | |
| 31 | <div class="col-lg-12 col-md-12"> | |
| 32 | <?php $engine= new Portal(); | |
| 33 | $engine->showMems(); | |
| 34 | ?> | |
| 35 | </div> | |
| 36 | </div> | |
| 37 | </div> | |
| 38 | </section> | |
| 39 | ||
| 40 | ||
| 41 | ||
| 42 | <----------------------------> | |
| 43 | PLIK Portal.php | |
| 44 | ||
| 45 | class Portal {
| |
| 46 | private $db; | |
| 47 | function __construct() | |
| 48 | {
| |
| 49 | $user= 'root'; | |
| 50 | $pass = ''; | |
| 51 | $this->db = new PDO('mysql:host=localhost;dbname=mems', $user, $pass);
| |
| 52 | } | |
| 53 | public function tekst(){
| |
| 54 | echo "siemanko!"; | |
| 55 | } | |
| 56 | public function showMems(){
| |
| 57 | $query = $this->db->prepare('SELECT * FROM memy');
| |
| 58 | $query->execute(); | |
| 59 | $show = $query->fetchAll(); | |
| 60 | foreach ($show as $value) {
| |
| 61 | echo '<div class="card" style="width: 100%">'; | |
| 62 | echo '<img src="images/img.jpg" class="card-img-top" alt="...">'; | |
| 63 | echo '<div class="card-body">'; | |
| 64 | echo '<p class="card-text">'.$value['title']. '</p>'; | |
| 65 | echo '<p class="card-text">'.$value['content'].'</p>'; | |
| 66 | echo '</div>'; | |
| 67 | echo '</div>'; | |
| 68 | } | |
| 69 | } | |
| 70 | } |