-
Posts
478 -
Joined
-
Last visited
-
Days Won
1
Posts posted by sagnik
-
-
I've a problem with my code. I want to fetch rows from mysql by category. I've 3 tables (categories,subcategories & childcategories). If the code works properly, it will look like,
categories=parent table, subcategories=children table of categories, childcategories=children of subcategories and sibling table of categoriescid,scid,ccid=unique numbers
cid=categories.cid (10digit), scid=subcategories.scid (8digit), ccid=childcategories.ccid (6digit)
HOW IT WILL LOOK IN HTML OUTPUT:
IF EVERY TABLE HAS CHILD ELEMENTS:- item-1
- item-1a
- item-1a1
- item-1b
- item-1b1
IF 1ST ROW IS A CHILD OF SUBCATEGORIES & 2ND ROW OF SUBCATEGORIES DOESN'T HAVE ANY CHILD ELEMENTS:
- item-1
- item-1a
- item-1a1
- item-1b
IF 1ST ROW IS A CHILD OF CATEGORIES & 2ND ROW OF CATEGORIES DOESN'T HAVE ANY CHILD ELEMENTS:
- item-1
- item-1a
- item-2
IF ANY OF CATEGORIES DOESN'T HAVE ANY CHILD ELEMENTS:
- item-1
- item-2
HOW IT LOOKS IN PHPMYADMIN:
table:categories
table:subcategories
table:childcategories
HERE IS THE CODES:
panels.php
<?php $db2 = $wnd->getDatabase("listings"); $wn = new WhatsNew($db2); foreach ($wn->getCategories() as $key => $cat) { if ($cat['subcats'] > 0) { if ($cat['childcats'] > 0) { echo '<div data-role="collapsible" data-inset="false" data-collapsed-icon="plus" data-expanded-icon="minus" data-iconpos="right" id="' . $cat['id'] . '">'; if ($cat['status'] == '2') { echo "<h3>" . $wn->getItemIcon($cat['cid'], "W_TAG-MAINCAT") . "<font color='grey'>{$cat['name']}</font></h3>"; } else { echo "<h3>" . $wn->getItemIcon($cat['cid'], "W_TAG-MAINCAT") . "{$cat['name']}</h3>"; } foreach ($wn->getSubCategories($cat['cid']) as $key => $subcat) { if ($subcat['childcats'] > 0) { echo '<div data-role="collapsibleset" data-theme="<?=$theme;?>" data-content-theme="<?=$content_theme;?>" data-inset="false" data-corners="false" style="padding:0px;margin-top:-10px;">'; echo '<div data-role="collapsible" data-collapsed-icon="carat-d" data-expanded-icon="carat-d" data-iconpos="right" data-inset="false">'; if ($subcat['status'] == '2') { echo "<h1 style='color:grey;'>" . $wn->getItemIcon($cat['cid'], $subcat['scid'], "W_TAG-SUBCAT") . "{$subcat['name']}</h1>"; } else { echo "<h1><a style='text-decoration:inherit;color:inherit;' href='#" . $subcat['scid'] . "'>" . $wn->getItemIcon($cat['cid'], $subcat['scid'], "W_TAG-SUBCAT") . "{$subcat['name']}</a></h1>"; } echo "<ul data-role='listview'>"; foreach ($wn->getChildCategories($cat['cid'], $subcat['scid']) as $key => $childcat) { if ($childcat['status'] == '2') { echo "<li style='color:grey;'>" . $wn->getItemIcon($cat['cid'], $subcat['scid'], $childcat['ccid'], "W_TAG-CHILDCAT") . "{$childcat['name']}</li>"; } else { echo "<li><a href='products.php?cid=" . $cat['cid'] . "&scid=" . $subcat['scid'] . "&ccid=" . $childcat['ccid'] . "'>" . $wn->getItemIcon($cat['cid'], $subcat['scid'], $childcat['ccid'], "W_TAG-CHILDCAT") . "{$childcat['name']}</a></li>"; } } echo "</ul>"; echo "</div></div>"; } else { echo "<ul data-role='listview'>"; if ($subcat['status'] == '2') { echo "<li style='color:grey;'>" . $wn->getItemIcon($cat['cid'], $subcat['scid'], "W_TAG-SUBCAT") . "{$subcat['name']}</li>"; } else { echo "<li style='margin:-8px;margin-top:-5px;padding-right:8px;padding-top:0px;padding-bottom:4px;'><a href='products.php?cid=" . $cat['cid'] . "&scid=" . $subcat['scid'] . "'>" . $wn->getItemIcon($cat['cid'], $subcat['scid'], "W_TAG-SUBCAT") . "{$subcat['name']}</a></li>"; } echo "</ul>"; } } echo "</div>"; } else { echo '<div data-role="collapsible" data-corners="false" data-inset="false" data-collapsed-icon="carat-d" data-expanded-icon="carat-d" data-iconpos="right" id="' . $cat['id'] . '">'; if ($cat['status'] == '2') { echo "<h3>" . $wn->getItemIcon($cat['cid'], "W_TAG-MAINCAT") . "<font color='grey'>{$cat['name']}</font></h3>"; } else { echo "<h3>" . $wn->getItemIcon($cat['cid'], "W_TAG-MAINCAT") . "{$cat['name']}</h3>"; } echo "<ul data-role='listview'>"; foreach ($wn->getSubCategories($cat['cid']) as $key => $subcat) { if ($subcat['status'] == '2') { echo "<li>" . $wn->getItemIcon($cat['cid'], $subcat['scid']) . "{$subcat['name']}</li>"; } else { echo "<li><a href='products.php?cid=" . $cat['cid'] . "&scid=" . $subcat['scid'] . "'>" . $wn->getItemIcon($cat['cid'], $subcat['scid'], "W_TAG-SUBCAT") . "{$subcat['name']}</a></li>"; } } echo "</ul> </div>"; } } else { echo "<ul data-role='listview'>"; if ($cat['status'] == '2') { echo "<li style='color:grey;'>" . $wn->getItemIcon($cat['cid'], "W_TAG-MAINCAT") . "{$cat['name']}</li>"; } else { echo "<li><a href='products.php?cid=" . $cat['cid'] . "'>" . $wn->getItemIcon($cat['cid'], "W_TAG-MAINCAT") . "{$cat['name']}</a></li>"; } echo "</ul>"; } } ?>
WhatsNew.base.php<?php function getCatType(){ $args=func_get_args(); $cid=$args[0]; $scid=$args[1]; $ccid=$args[2]; $ccid=$args[3]; $ret=array(); if(empty($cid) && empty($ccid) && empty($scid) || !is_numeric($cid) && !is_numeric($ccid) && !is_numeric($scid)){ $ret['query_name']="Categories"; $ret['query_table']="categories"; } elseif((!empty($cid) && is_numeric($cid)) && (empty($ccid) && empty($scid) || !is_numeric($ccid) && !is_numeric($scid))){ $ret['query_name']="Categories"; $ret['query_table']="categories"; $ret['query_table_condition']="cid='$cid'"; } elseif((!empty($cid) && !empty($scid) && is_numeric($cid) && is_numeric($scid)) && (empty($ccid) && !is_numeric($ccid))){ $ret['name']="Categories"; $ret['table']="Categories"; $ret['query_name']="Sub-categories"; $ret['query_table']="subcategories"; $ret['query_table_condition']="cid='$cid' AND scid='$scid'"; } elseif(!empty($cid) && !empty($scid) && !empty($ccid) && is_numeric($cid) && is_numeric($scid) && is_numeric($ccid)){ $ret['name']="Sub-categories"; $ret['table']="subcategories"; $ret['query_name']="Child-categories"; $ret['query_table']="childcategories"; $ret['query_table_condition']="cid='$cid' AND scid='$scid' AND ccid='$ccid'"; } elseif(!empty($cid) && !empty($scid) && !empty($ccid) && !empty($pid) && is_numeric($cid) && is_numeric($scid) && is_numeric($ccid) && is_numeric($pid)){ $ret['name']="Child-categories"; $ret['table']="childcategories"; $ret['query_name']="Products"; $ret['query_table']="products"; $ret['query_table_condition']="cid='$cid' AND scid='$scid' AND ccid='$ccid' AND pid='$pid'"; } return $ret; } function getOidParams($param=array()){ $return=array(); foreach($param as $key){ if(is_numeric($key)){ if(strlen($key)==10){ $return['cid']=$key; } if(strlen($key)==8){ $return['scid']=$key; } if(strlen($key)==6){ $return['ccid']=$key; } if(strlen($key)==4){ $return['pid']=$key; } } } return $return; } function isIconHidden(){ $args=func_get_args(); $cid=$args[0]; $scid=$args[1]; $ccid=$args[2]; if($q=db_query("SELECT showicon FROM $this->getCatType($cid,$scid,$ccid)['table'] WHERE $this->getCatType($cid,$scid,$ccid)['query_table_condition']",$this->db)){ if(db_num_rows($q)>0){ $r=db_fetch_array($q); return $r['showicon']; } } } function getItemIcon(){ $args=func_get_args(); $param=array($args[0],$args[1],$args[2],$args[3]); $tbl=$this->getCatType($this->getOidParams($param)['cid'],$this->getOidParams($param)['scid'],$this->getOidParams($param)['ccid'],$this->getOidParams($param)['pid'])['query_table']; $tbl_cond=$this->getCatType($this->getOidParams($param)['cid'],$this->getOidParams($param)['scid'],$this->getOidParams($param)['ccid'],$this->getOidParams($param)['pid'])['query_table_condition']; if($q=db_query("SELECT icon,icon_mime FROM $tbl WHERE $tbl_cond",$this->db)){ if(db_num_rows($q)>0){ $r=db_fetch_array($q); if($r['showicon']==0){ return ""; } elseif($r['showicon']==1){ if(in_array("W_TAG-MAINCAT",$param)){ $ret="<div style='float:left;;'><img src='".bin2file($r['icon'],$r['icon_mime'])."' width='24' height='24'/></div>"; } elseif(in_array("W_TAG-SUBCAT",$param)){ $ret="<div style='float:left;'><img src='".bin2file($r['icon'],$r['icon_mime'])."' width='24' height='24'/></div>"; } elseif(in_array("W_TAG-CHILDCAT",$param)){ $ret="<div style='float:left;margin-left:10px;'><img src='".bin2file($r['icon'],$r['icon_mime'])."' width='24' height='24'/></div>"; } elseif(in_array("W_TAG-PRODUCTCAT",$param)){ $ret="<div style='float:left;margin-left:15px;'><img src='".bin2file($r['icon'],$r['icon_mime'])."' width='24' height='24'/></div>"; } else { $ret=bin2file($r['icon'],$r['icon_mime']); } return $ret; } } } else { echo error("Unable to query database! {$this->hcMsg}"); } } function getSubCategoriesCount($cid){ $sccq=db_query("SELECT scid FROM subcategories WHERE cid='$cid' AND status != '1' ORDER BY name ASC",$this->db); if($sccq){ if(db_num_rows($sccq)>0){ $sccr=db_fetch_array($sccq); $result=array("subcategories"=>array("scid"=>$sccr['scid'],"count"=>db_num_rows($sccq))); } else { $result=array("scid"=>"NULL","count"=>"0"); } return $result; } else { echo error("Unable to query database! {$this->hcMsg}"); } } //END FUNCTION: getSubCategoryCounts() function getChildCategoriesCount($cid,$scid){ $cccq=db_query("SELECT ccid FROM childcategories WHERE cid='$cid' AND scid='$scid' AND status != '1' ORDER BY name ASC",$this->db); $result=array(); if($cccq){ if(db_num_rows($cccq)>0){ $cccr=db_fetch_array($sccq); $result=array("childcategories"=>array("ccid"=>$cccr['ccid'],"count"=>db_num_rows($cccq))); } else { $result=array("ccid"=>"NULL","count"=>"0"); } return $result; } else { echo error("Unable to query database! {$this->hcMsg}"); } } //END FUNCTION: getChildCategoryCounts() function getProductsCount(){ $args=func_get_args(); $cid=$args[0]; $scid=$args[1]; $ccid=$args[2]; if(!empty($cid) && !empty($scid) && !empty($ccid) && is_numeric($cid) && is_numeric($scid) && is_numeric($ccid)){ $pcq=db_query("SELECT pid FROM products WHERE cid='$cid' AND scid='$scid' AND ccid='$scid' AND status != '1' ORDER BY name ASC",$this->db); } elseif((!empty($cid) && !empty($scid) && is_numeric($cid) && is_numeric($scid)) && (empty($ccid) && !is_numeric($ccid))){ $pcq=db_query("SELECT pid FROM products WHERE cid='$cid' AND scid='$scid' AND ccid='' AND status != '1' ORDER BY name ASC",$this->db); } elseif((!empty($cid) && is_numeric($cid)) && (empty($ccid) && empty($scid) || !is_numeric($ccid) && !is_numeric($scid))){ $pcq=db_query("SELECT pid FROM products WHERE cid='$cid' AND scid='' AND ccid='' AND status != '1' ORDER BY name ASC",$this->db); } if($pcq){ if(db_num_rows($pcq)>0){ return db_num_rows($pcq); } else { echo error("No products found in any categories!"); } } else { echo error("Unable to query database! {$this->hcMsg}"); } } //END FUNCTION: getProductsCount() function getCategories(){ $cq1=db_query("SELECT * FROM categories WHERE status != '1' ORDER BY name ASC",$this->db); if($cq1){ if(db_num_rows($cq1)>0){ $result=array(); while($cr1=db_fetch_array($cq1)){ foreach($cr1 as $key => $subArr){ unset($cr1['icon']); unset($cr1['icon_mime']); unset($cr1[2]); unset($cr1[3]); } $cr1["subcats"]=$this->getSubCategoriesCount($cr1['cid'])['count']; $cr1["childcats"]=$this->getChildCategoriesCount($cr1['cid'],$this->getSubCategoriesCount($cr1['cid'])['scid'])['count']; array_push($result,$cr1); } return $result; } else { echo error("No categories found!"); } } else { echo error("Unable to query database! {$this->hcMsg}"); } } //END FUNCTION: getCategories() function getSubCategories($cid){ $scq1=db_query("SELECT * FROM subcategories WHERE cid='$cid' AND status != '1' ORDER BY name ASC",$this->db); if($scq1){ if(db_num_rows($scq1)>0){ $result = array(); while($scr1=db_fetch_array($scq1)){ foreach($scr1 as $key => $subArr){ unset($scr1['icon']); unset($scr1['icon_mime']); unset($scr1[2]); unset($scr1[3]); } if($ccq=db_query("SELECT ccid FROM childcategories WHERE cid='$cid' AND scid='".$scr1['scid']."' AND status != '1' ORDER BY name ASC",$this->db)){ if(db_num_rows($ccq)>0){ while($ccr=db_fetch_array($ccq)){ $scr1["childcats"]=db_num_rows($ccq); } } else { $scr1["childcats"]="0"; } } else { $scr1["childcats"]="0"; } array_push($result,$scr1); } return $result; } else { echo error("No sub-categories found!"); } } else { echo error("Unable to query database! {$this->hcMsg}"); } } //END FUNCTION: getSubCategories() function getChildCategories($cid,$scid){ $ccq1=db_query("SELECT * FROM childcategories WHERE cid='$cid' AND scid='$scid' AND status != '1' ORDER BY name ASC",$this->db); if($ccq1){ if(db_num_rows($ccq1)>0){ $result = array(); while($ccr1=db_fetch_array($ccq1)){ foreach($ccr1 as $key => $subArr){ unset($ccr1['icon']); unset($ccr1['icon_mime']); unset($ccr1[2]); unset($ccr1[3]); } array_push($result,$ccr1); } return $result; } else { echo error("No child-categories found!"); } } else { echo error("Unable to query database! {$this->hcMsg}"); } } //END FUNCTION: getChildCategories() ?>
-
Thank you very much for your help sir. Let's see if I can find any settings about Google proxy.
-
No. When I visit "whatsmyip.org" from my pc, it's showing the External IP which was assigned to/by my ISP. And when I'm doing the same from my mobile, it's showing a completely different IP which was assigned by Google I think. Here is what I see from my mobile:
Your IP Address is 64.233.173.145
Your Host Name:
google-proxy-64-233-173-145.google.com
Your User Agent:
Mozilla/5.0 (Linux; Android 6.0; Le X509 Build/DHXOSOP5801911241S) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.83 Mobile Safari/537.36
-
My device doesn't allow to turn on WiFi, Hotspot & Mobile Data in Airplane Mode. And I always turn off Mobile Data when I turn on WiFi.
-
Ok thanks sir. And one more thing, I'm able to access the cPanel without any problems from my pc. The problem is occurring only if I try to access cPanel from my mobile. Both devices connected to the internet through same WiFi network, then why I'm able to access cPanel from PC but not from my mobile?
-
Sir, I've just visited the site you have mentioned, in there my IP is not changing but in whatsmyip.org my IP keeps changing. Well I'm using VPNEasy in android as you suggested to use a proxy.
-
How can I use a proxy?
I've just checked my Internet configuration and found that I've a static IP assigned by my ISP. I think my router changing it's IP.
My router assigns a IP, but when I'm visiting "whatsmyip.org" it's giving an IP completely different. And a hostname "google-proxy-64-233-173-146.google.com".
-
My ISP does not provides a static IP to individuals.
I'm using VPNEasy in android with Google Chrome it's doesn't work. It always changing the last digit of IP.
-
Everytime I'm trying to login, I'm getting "Your IP address has changed". I'm connected via a Wi-Fi networkabd NY IP constantly changing. I think I can't get a static IP so I've used a VPN but it's also keeps changing it's last digit of IP. What can I do to prevent this?
-
Thanks sir, it's working now.
-
No sir, it's not working. I've already checked on my mobile and now I've just checked in my pc, both are not working.
-
I've not tried yet. Let me check.
-
I'm unable to access the cPanel of Tommy. I'm getting "Connection timeout" error everytime I'm trying to login.
-
I'm not sure, but you can use PayPal. Because I've done the same via PayPal. The domain was made by my friend and I've asked Krydos sir to change the email to my email and he did that.
-
Thanks sir
-
Sir I've sent the details with PM
-
Sir, I've just made a transaction of 2$ and recieved the Tommy invitation. And I want to change the email as the donation was made from my friend.
-
Yeah, PayPal is allowing to link bank account. When read, I came to know that, it will be used for withdrawal only. I can't do any payments through it.
-
Not sure about Skrill but PayPal is not accepting my card.
-
Yeah, sure. How can I make the payment?
As my debit card is India only, there is no chance to make payment through it.
-
I'll try to link my bank account and see if it works. And if I wait until 5:30am, can I signup for Tommy? I don't want to signup for any other server.
-
Is there any other methods to pay except PayPal, I've already checked PayPal and it doesn't support Rupay card.
-
Well I've a Rupay Debit Card. Is it supported to make the transaction using "https://heliohost.org/tommy"?
-
I want to create an account on Tommy. I want to know how much I need to donate to get an invitation from HelioHost. I'm asking this question because, I've never done any transactions online before. So I don't want to make a large transaction. And I'm from India, if I donate USD 1$, I've to pay R.s 64.67₹ + bank charges.
Need Help To Fix A Php Code
in Website Management and Coding
Posted
I've a problem with my code. I want to fetch rows from mysql by category. I've 3 tables (categories,subcategories & childcategories). If the code works properly, it will look like,
HOW IT WILL LOOK IN HTML OUTPUT:
IF 1ST ROW IS A CHILD OF CATEGORIES & 2ND ROW OF CATEGORIES DOESN'T HAVE ANY CHILD ELEMENTS:
- item-1
- item-1a
- item-2
IF ANY OF CATEGORIES DOESN'T HAVE ANY CHILD ELEMENTS:
- item-1
- item-2
HOW IT LOOKS IN PHPMYADMIN:
table:categories
table:subcategories
table:childcategories
HERE IS THE CODES:
panels.php
WhatsNew.base.php