Пример #1
0
 function __construct($id = -1)
 {
     if (self::$conn == Null) {
         self::$conn = mysqli_connect('localhost', 'root', 'iti', 'GEO');
     }
     if ($id != -1) {
         $query = "select * from sub_cato where id_cato={$id_cato} and id_sub={$id_sub} limit 1";
         $result = mysqli_query(self::$conn, $query);
         $prod = mysqli_fetch_assoc($result);
         $this->id_cato = $prod['id_cato'];
         $this->id_sub = $prod['id_sub'];
         $this->name_sub = $prod['name_sub'];
     }
 }
Пример #2
0
 }
 $Ncato == 0;
 $Nsub == 0;
 $cat_res = "select * from cato ";
 $OPut = mysqli_query($conn, $cat_res);
 // $crow = mysqli_fetch_assoc($OPut);
 while ($crow = mysqli_fetch_assoc($OPut)) {
     $xx = $crow['name_cato'];
     if ($cato == $xx) {
         $Ncato = $crow['id_cato'];
         // var_dump("$Ncato");
         break;
     }
 }
 // var_dump("$Ncato");
 $sub = new Subcato();
 $chsub = $sub->idsub_cato($Ncato);
 // var_dump($chsub);
 $N = count($chsub);
 $Num = $N + 1;
 $Nsub = $Num;
 // echo $Nsub;
 $sub->id_sub = $Nsub;
 $sub->id_cato = $Ncato;
 $sub->name_sub = $typesub;
 // var_dump($sub);die();
 $sub->insert();
 // echo "<a href='profile.php'>aaa<a/>";
 if ($Ncato == 0 || $Nsub == 0) {
     header("location:insert_products.php");
 }
Пример #3
0
<?php

session_start();
require 'class_cato.php';
require 'class_subcato.php';
$conn = mysqli_connect('localhost', 'root', 'iti', 'GEO') or die("Can not connect to db");
// $errors = [];
if (isset($_POST['send'])) {
    if ($_POST['send'] == 'Update') {
        if ($_POST['type_sub'] == 'SUB_CATO') {
            $typesub = "You are not allowed";
        } else {
            $typesub = $_POST['type_sub'];
        }
    }
    $sub = new Subcato();
    if (isset($_GET['update'])) {
        $values = explode(",", $_GET["update"]);
        // echo count($values) ;
        // print_r($values);die();
    }
    $sub->name_sub = $typesub;
    $idc = $values[0];
    $ids = $values[1];
    $sub->updateWithId($idc, $ids);
    var_dump($sub);
    // echo "<a href='profile_sub_cato.php'>aaa<a/>";
    echo "<meta http-equiv='Refresh' content='0;url=profile_sub_cato.php' />";
} else {
    header("location:sub_update.php");
}