Hello i want a solutions for categories off subcategories in array n level .
- 1 like
- 1 comment
Mukund verma |08 Sep at 11:09
Hello i want a solutions for categories off subcategories in array n level .
Sanjana Kumari08 Sep at 12:09
<?php
$hostname = "localhost";
$db_username = "root";
$db_password = "";
$db_name = "test";
$db = new mysqli($hostname, $db_username, $db_password, $db_name);
class categoryss {
public function get_categories($id){
global $db;
$querycat='';
$gcategories=array();
if(is_null($id)){
$querycat = "SELECT cat_id,cat_name,parent_id FROM categories WHERE parent_id='0'";
}else{
$querycat = "SELECT cat_id,cat_name,parent_id FROM categories WHERE parent_id='".$id."'";
}
$result = $db->query($querycat);
if($result->num_rows>0){
while($row=$result->fetch_assoc()){
if(!empty($row['cat_id']) && $row!=''){
$gcategories[]=$row;
if(!empty($this->get_categories($row['cat_id']))){
$gcategories[]['child']=$this->get_categories($row['cat_id']);
}
}
}
}
return $gcategories;
}
////////////////////////////////////////
}
$obj=new categoryss();
$getNlevelCategory=$obj->get_categories('0');
/*echo "<pre>";
print_r($getNlevelCategory);*/
function traverseArray($array) {
if(is_array($array)){
foreach($array as $vals) {
echo @$vals['cat_name'] . "<br>";
traverseArray(@$vals['child']). "\n";
}
}
}
echo traverseArray($getNlevelCategory);
?>
Dhananjay Kumar |22 May at 12:05
I need to change URL in my post content , suggest query to quick replace all.
Veer Sreenivas |24 Apr at 01:04
Hi, I need help to integrate Paytm payment gateway on web and APP.
Can anyone here share step by step process with sample code to do the same.
I am using PHP as backend langauge.
thanks in advance.
Manas Mayank |03 Apr at 11:04
I have uploaded my project Digital Ocean LEMP and getting issue with
1. Datatype datetime - 0000-00-00 00:00:00 is not valid date type
2. Datatype Integer - Incorrect integer value for column name at row 1
3. Datatype Float - Data truncated for column for column name at row 1
Basically these error were coming at insert and update time, as proper datatype was not coming from php end.
I cannot change php end as project is live.
How to dissolve these issues. thanks in advance
Dhananjay Kumar03 Apr at 12:04
I am getting the same issues & i have updated MySQL settings and its work fine for me.
You go in a file : /etc/mysql/mysql.conf.d/mysqld.cnf
and add below script at end of line
sql_mode = "NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
After adding restart your MySQL: sudo service mysql restart
Please try, its really work.