Jump to content

rayus

Member
  • Posts

    5
  • Joined

  • Last visited

rayus's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Spot on thats what I was looking for!
  2. Thanks for the offer and hints so far but I got some what further: I changed the setData Methode in the Template: function setData($name, $value){ //set data #$this->data[$name] = htmlentities($value, ENT_QUOTES); $this->data[$name] =$value; } I think I all most got the required data in the view now. I will try to change the PHP in the view.
  3. The template class only contains default code from the example. And line 9 is the first line of the class {. Don't thing there is the problem. I have to use the 2 methods you mentioned. Then I have to change the setDatamethod to except an array or object? like: In the controler: $Template->setData("Sites_data",$Users->getSites()); In the view: $result = $Template->getData("Sites_data"); Loop trough the properties
  4. Fatal error: Cannot redeclare class Template in D:\wamp\www\admr\models\m_template.php on line 9 included the model in init.php like the auth model. If i understand correct. all the business logic needs to be in de model. So I only have to instantiate the class in the controler? But how does the view know about the class. It has only acces to the template class.
  5. I was very pleased with the PHP login videos, excelent! I'am trying to extend the application with a simple user model and user controller and view. My goal is a simple display of a query in the user view displaying some information. In my controller all the properties and methods are availabl but how do i display them in the view: My user class contains the following: <?php /* User Class Deal with user tasks tasks and sites */ class Users{ function __construct() { #global $Database; } function getSites(){ // get all sites global $Database; // Query database $result = $Database->query("SELECT SiteCode FROM site ORDER BY SiteCode ASC"); $sites = $result->fetch_array(MYSQLI_ASSOC); return $sites; // free result set. $result->close(); } function getUsers(){ global $Database; // get all Users $result = $Database->query("Select * FROM user ORDER BY Displayname "); return $result; // free result set $result->close(); } function getUsersPerSite(){ // Users per site matched on city // error handeling global $Database; // query database $result = $Database->query( "SELECT * FROM user INNER JOIN site ON user.l = site.City ORDER BY SiteCode"); if( $result->num_rows != 0) { return $result; } else{ echo "no results"; } // free result set $result->close(); } function getLastUpdated(){ // display last updated database import Active directory global $Database; $result = $Database->query( "SELECT DISTINCT creationdate FROM user"); $date = $result->fetch_row(); return $date; // free result set $result->close(); } function getStatusSite($siteCode,$status){ //Gegevens op halen global $Database; $result = $Database->query( "SELECT * FROM user INNER JOIN site ON user.l = site.City WHERE SiteCode = '$siteCode' and status= '$status'"); if( $result->num_rows != 0){ return $result; } else { #echo "No users for this status on site " . $siteCode . "<br/>"; return false; } } } ?> And my controler contains: <?php include ('includes/database.php'); include("includes/init.php"); // check authorization if ($Auth->checkLoginStatus() == FALSE) { $Template->setAlert('Unauthorized!', 'error'); $Template->redirect('login.php'); } else { //Meta data $LastUpdate = $Users->getLastUpdated(); $TotalSites= $Users->getSites(); //load sites and meta data $Sites = $Users->getSites(); $LastUpdate ->getLastUpdated(); $Template->load("views/v_admr.php"); } ?> The view needs to display the $Sites in a table, but thats not an issue. I recieve errors about the template model? But how does it fit in?
×
×
  • Create New...