Last active
January 11, 2016 14:58
-
-
Save VictorFursa/726ca1a14c712b477c9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| include_once("connectDatabases.php"); | |
| class GuestBook{ | |
| private $firstName; | |
| private $email; | |
| private $message; | |
| function __construct($firstName,$email,$message){ | |
| $this->firstName = $firstName; | |
| $this->email = $email; | |
| $this->message = $message; | |
| } | |
| function getText(){ | |
| return "<b><em>Имя автора</b></em>: " . $this->firstName . "<br> <b><em>Почта: </b></em> " . " $this->email " . " <br> <b><em>Сообщение:</b></em> ". $this->message; | |
| } | |
| function save(){ | |
| return mysql_query (" INSERT INTO guest_book (firstName,email,message) | |
| VALUES(' {$this->firstName} ' , ' {$this->email} ' , ' {$this->message} ' )"); | |
| } | |
| static function getALL(){ | |
| $a = 1; | |
| $result = mysql_query("SELECT * FROM guest_book "); | |
| $array = array(); | |
| while ($categories = mysql_fetch_array($result)) { | |
| $array[] = $categories; | |
| } | |
| foreach($array as $key =>$value){ | |
| echo "<b>№" . $a++ . | |
| "<b> Имя </b>: " . $value['firstName'] ."<br>" . | |
| "<b> <em> Текст: </em></b>" . $value['message'] . "<hr>"; | |
| } | |
| } | |
| } | |
| $name = 'Виктор'; | |
| $object = new GuestBook( $name ,'[email protected]','HELL'); | |
| GuestBook::getALL(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment