Plik text.class.php
<?
//* Połączenie Mysql za pomocą PDO, a następnie klasa
class text {
var $db;
public function __Construct($db) {
$this->db=$db;
}
public function read($bind=null) {
$return = array();
$stmt = $this->db->prepare("SELECT id, tytul, text FROM text WHERE id = :id");
$stmt->bindValue(':id', $_GET['id'], PDO::PARAM_INT);
$stmt->execute($bind);
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$return[] = $row;
}
return $return;
}
$text = new text($pdo);
?>
//* Połączenie Mysql za pomocą PDO, a następnie klasa
class text {
var $db;
public function __Construct($db) {
$this->db=$db;
}
public function read($bind=null) {
$return = array();
$stmt = $this->db->prepare("SELECT id, tytul, text FROM text WHERE id = :id");
$stmt->bindValue(':id', $_GET['id'], PDO::PARAM_INT);
$stmt->execute($bind);
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$return[] = $row;
}
return $return;
}
$text = new text($pdo);
?>
Plik text.php
<?php
require_once("text.class.php");
$text = $text->read();
foreach($text as $row)
{
echo "$row['tytul'] <br> $row['text']";
}
?>
require_once("text.class.php");
$text = $text->read();
foreach($text as $row)
{
echo "$row['tytul'] <br> $row['text']";
}
?>
Mam nadzieję, że komuś pomogłem. Pozdrawiam
Brak komentarzy:
Prześlij komentarz