getParents(); } public functi : Notes">

NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<?php

class DB extends mysqli
{
public $parents = [];
public function __construct($hostname,$username,$password,$db){
parent::__construct($hostname,$username,$password,$db);
mysqli_set_charset($this,"utf8");
$this->getParents();
}
public function getAllDataByTableName($tablename){
$sql = "SELECT * from ".$tablename;
$result = $this->query($sql);
$allDatas = [];
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
array_push($allDatas,$row);
}
}
return $allDatas;
}
public function getAllData($sql){
$result = $this->query($sql);
$allDatas = [];
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
array_push($allDatas,$row);
}
}
return $allDatas;
}
public function getParents(){
$sql = "SELECT * from categories where parentid = -1";
$result = $this->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
array_push($this->parents,$row["katid"]);
}
}
}

public function createTemplate($template,$datas){
preg_match_all("/{%(.+?)%}/",$template,$result);
$keywords = $result[1];
$replace = $result[0];
foreach ($datas as $key => $value) {
$temp = $template;
for ($i=0; $i < count($replace); $i++) {
$temp = str_replace($replace[$i], $value[$keywords[$i]], $temp);
}
echo $temp;
}

}

public function recursive($id=-1){
$categories = [];
$sql = "SELECT * from categories where parentid=".$id;
$result = $this->query($sql);
$datas = [];
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
array_push($datas,$row);
}
}
foreach ($datas as $key => $value) {
if($id == -1){

echo '<div class="panel panel-default">'.PHP_EOL;
echo '<div class="panel-heading">'.PHP_EOL;
echo '<h4 class="panel-title">'.PHP_EOL;
echo '<a data-toggle="collapse" data-parent="#accordian" href="#'.str_replace(' ','',$value['katadi']).'">'.PHP_EOL;
echo '<span class="badge pull-right"><i class="fa fa-plus"></i></span>'.PHP_EOL;
print_r($value["katadi"]);
echo '</a>'.PHP_EOL;
echo '</h4>'.PHP_EOL;
echo '</div>'.PHP_EOL;
echo '<div id="'.str_replace(' ','',$value["katadi"]).'" class="panel-collapse collapse">'.PHP_EOL;
echo '<div class="panel-body">'.PHP_EOL;
echo '<ul>'.PHP_EOL;
echo '<li><a href=""></a></li>'.PHP_EOL;
}else{
if(in_array($id, $this->parents)){
echo "<li style='margin-left:10px'><a href='urunler.php'>".$value["katadi"]."</a></li>".PHP_EOL;
}else{
echo "<li style='margin-left:20px'><a href='urunler.php'>-".$value["katadi"]."</a></li>".PHP_EOL;

}

}
$this->recursive($value["katid"]);
if($id==-1){
echo "</ul>
</div>
</div>
</div>";
}
}

}
public function rec_mobile($id=-1){
$sql = "SELECT * from categories where parentid=".$id;
$result = $this->query($sql);
$datas = [];
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
array_push($datas,$row);
}
}
foreach ($datas as $key => $value) {
if($id == -1){
echo "<li class='dropdown-submenu'><a class='dropdown-item dropdown-toggle' href='#' style='color:orange;'>".$value["katadi"]."</a>
<ul class='dropdown-menu'>";
}else{
echo '<li><a class="dropdown-item" href="#">'.$value["katadi"].'</a></li>';
}
$this->rec_mobile($value["katid"]);
if($id == -1){
echo "</ul></li>";
}
}
}

public function recursive2($id=-1){
$categories = [];
$sql = "SELECT * from categories where parentid=".$id;
$result = $this->query($sql);
$datas = [];
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
array_push($datas,$row);
}
}
echo "<ul>";
foreach ($datas as $key => $value) {
if($value["parentid"] == -1){
echo "<li style='color:orange'>";
}else{
echo "<li>";

}
echo $value["katadi"];
$this->recursive($value["katid"]);
echo "</li>";
}
echo "</ul>";

}

public function rec_cat($id = -1){
$sql = "SELECT * from categories where parentid=".$id;
$result = $this->query($sql);
echo "<ul>";
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo '<li><a href="#">$value["katadi"]</a>';
'<li><a href="#" style="font-size:12px;">$row["katadi"]</a></li>';
echo "</ul>";}}
}

public function getProduct($id){
$sql = "SELECT * from products where id=".$id;
$result = $this->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
return array($row["id"],$row["product_name"],$row["price"],$row["image"],$row["descr"],$row["old_price"]);
}
}
}
$db = new DB("localhost","root","","rec");
//$db->rec_mobile();
?>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.