コード例 #1
0
 public function load($id)
 {
     $db = new Database();
     $query = "select * from `itm_products` where (id = {$id})";
     //echo $query;//####This is to be commented
     $result = $db->execute_query_return_result($query);
     $rp = new Result_processor();
     $fields = array('id', 'name', 'description', 'unit');
     $arr = $rp->get_array_of($result, $fields);
     $this->id = $id;
     $this->name = $arr[0]['name'];
     $this->description = $arr[0]['description'];
     $this->unit = $arr[0]['unit'];
     //echo $this->id." ".$this->name;
 }
コード例 #2
0
ファイル: index.php プロジェクト: rajanpupa/database_design
<?php

//session handeling and processing section
session_start();
$_SESSION['id'] = rand(1000, 10000);
include_once "libraries/items_class.php";
include_once "libraries/DataBase/result_processor_class.php";
$items = new Item();
$result = $items->get_result_root_categories();
$rp = new Result_processor();
$arr = array("id", "name");
$categories = $rp->get_array_of($result, $arr);
$body = "";
//print_r($categories);
foreach ($categories as $category) {
    //echo " The product is <br/>".$category['name']."";
    $products = $items->get_array_products($category['id']);
    //print_r($products);
    $body .= "<div class=\"category\">" . $category['name'] . "<ul>";
    foreach ($products as $product) {
        $body .= "<li><a href=\"details.php?id=" . $product['id'] . "\">" . $product['name'] . "</a></li>";
    }
    $body .= "</ul></div>";
    //category
}
//echo $body;
//die();
//Required variables initialization section
/*
 * variables to be defined are-:
 *	$image_path, points to the location of the header image "./public/images/header1.jpg"