php - Query result data is displaying after page reload -
this code.
index.php file:
$viewer_id = $_session['viewer_id']; $db = new database('144.76.6.45','5432','3331','asd','31sd23'); $db->queryselect("select * users vk_id = $viewer_id"); $row = $db->sth->fetch(); if(empty($row)){ require 'template/default/not_logged.php'; } else { require 'template/default/logged.php'; }
this part understandable. connecting database, doing query. if viewer's id in db - logged.php if not - not_logged.php
lets viewers id in db.
logged.php file:
<div id="text-right"> <p>Игровой ник: <?php $user->geteuname(); ?></p> <p>cоциум: <?php $user->getsociety(); ?></p> <p>Основная профессия: <?php $user->getmainprofession(); ?></p> <p>Дополнительная информация: <?php $user->getnotes(); ?></p> <p>Ищу команду для совместной охоты: <?php $user->getwantteam(); ?></p> <div class="edit-info"><a href="#">Редактировать</a></div> </div>
this methods getting info db.
class user extends database { public $vk_id; public $eu_name; public $eu_society; public $eu_notes; public $eu_want_team; public $eu_data; function __construct() { parent::__construct('144.76.6.45','5432','eu','eu','eu123'); } function geteuname() { $this->queryselect("select eu_name users vk_id = $this->viewer_id"); $row = $this->sth->fetch(); print '<b>'.$row['eu_name'].'</b>'; } function getsociety() { $this->queryselect("select eu_society users vk_id = $this->viewer_id"); $row = $this->sth->fetch(); print '<b>'.$row['eu_society'].'</b>'; } function getnotes() { $this->queryselect("select eu_notes users vk_id = $this->viewer_id"); $row = $this->sth->fetch(); print '<b>'.$row['eu_notes'].'</b>'; } function getwantteam() { $this->queryselect("select eu_want_team users vk_id = $this->viewer_id"); $row = $this->sth->fetch(); if($row['eu_want_team'] == 'true') { print '<b>Да</b>'; } else { print '<b>Нет</b>'; } } function getmainprofession() { $this->queryselect("select eu_main_profession users vk_id = $this->viewer_id"); $row = $this->sth->fetch(); print '<b>'.$row['eu_main_profession'].'</b>'; } } $user = new user();
and user class methods.(he included in index.php database.php(db connection class) is).
everything ok, when viewer comes page, data of methods(query results) doesn't show, show after reload! don't know whats problem. please solution.
thanks!
Comments
Post a Comment