Jump to content

karthikanov24

Members
  • Posts

    54
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

karthikanov24's Achievements

Member

Member (2/5)

0

Reputation

  1. hi function formatCategories($categories, $parentId) { // $navCat stores all children categories // of $parentId $navCat = array(); // expand only the categories with the same parent id // all other remain compact $ids = array(); foreach ($categories as $category) { if ($category['cat_parent_id'] == $parentId) { $navCat[] = $category; } // save the ids for later use $ids[$category['cat_id']] = $category; } print_r($ids[$category[0]]); If i am printing the array using, print_r($ids[$category[0]]);here 0 is the start key of the array(as shown in last line of codes)..OR print_r($ids[$category[12]]); here 12 is the cat_id of a product... I am getting notice as,Notice: Undefined offset: 0. without out the display of expected output.. But if i use print_r($ids); i get, Array ( [12] => Array ( [cat_id] => 12 [cat_parent_id] => 0 [cat_name] => Cars [cat_image] => dce08605333d805106217aaab7f93b95.jpg [cat_description] => Expensive and luxurious cars ) [13] => Array ( [cat_id] => 13 [cat_parent_id] => 0 .................................etc.... And if i use print_r($ids[$category['cat_id']]);after for each loop i get, Array ( [cat_id] => 17 [cat_parent_id] => 13 [cat_name] => Hunter X Hunter [cat_image] => 746e05a7a629d53bc488115a75ee35d9.jpg [cat_description] => Story about hunter and combat ) The question is why do i get notice of undefined offset after using those,print_r($ids[$category[0]]);(as shown in last line of codes)..OR print_r($ids[$category[12]]); statements instead of expected output.. could you explain this please.. thanks karthikanov24
  2. hi array_multisort($parent); $parent displays the following array before multisorting...as follows.. Array ( [0] => Array ( [cat_id] => 15 [cat_parent_id] => 12 [cat_name] => Mercedes-Benz [cat_image] => e40c0b24095b3b5284cb5f64ab394b5a.jpg [cat_description] => Expensive but real good ) [1] => Array ( [cat_id] => 14 [cat_parent_id] => 12 [cat_name] => Volvo [cat_image] => 45ad4ebcdc58193534aabc6dc9c1a022.jpg [cat_description] => Swedish luxury car ) ) After using array_multisort() as shown in the code it displays as follows... Array ( [0] => Array ( [cat_id] => 14 [cat_parent_id] => 12 [cat_name] => Volvo [cat_image] => 45ad4ebcdc58193534aabc6dc9c1a022.jpg [cat_description] => Swedish luxury car ) [1] => Array ( [cat_id] => 15 [cat_parent_id] => 12 [cat_name] => Mercedes-Benz [cat_image] => e40c0b24095b3b5284cb5f64ab394b5a.jpg [cat_description] => Expensive but real good ) ) what has been changed here after using array_multisort() in the above array...? (how it is sorted..?) thanks karthikanov24
  3. hi what are the values of $i,the for loop takes and at what value of $i it enters the last if loop to print whether it leaves the for loop when $i reaches the value '1' or leaves after increasing to value '2'...? $categoryList = getCategoryList(); $categoriesPerRow = 3; $numCategory = count($categoryList); $columnWidth = (int)(100 / $categoriesPerRow); ?> <table width="100%" border="0" cellspacing="0" cellpadding="20"> <?php if ($numCategory > 0) { $i = 0; for ($i; $i < $numCategory; $i++) { if ($i % $categoriesPerRow == 0) { echo '<tr>'; } // we have $url, $image, $name, $price extract ($categoryList[$i]); echo "<td width=\"$columnWidth%\" align=\"center\"><a href=\"$url\"><img src=\"$image\" border=\"0\"><br>$name</a></td>\r\n"; if ($i % $categoriesPerRow == $categoriesPerRow - 1) { echo '</tr>'; } } if ($i % $categoriesPerRow > 0) { echo '<td colspan="' . ($categoriesPerRow - ($i % $categoriesPerRow)) . '"> </td>'; } } else {
  4. hi Is this correct...? if(count(getChildCategories($categories,$catId))>0) echo "have values"; else echo "empty"; Actually i want to check the value of getChildCategories() alone...and not others.. Please could you help me.... thanks karthikanov24
  5. hi In the above posting,there is no variable like $array .There is only function getChildCategories() having array..... so could you give the code using that function to check the value in it...please.. thanks karthikanov24
  6. hi $child = array_merge($child, getChildCategories($categories, $catId)); In the above line of code,the value(return value) of the function getChildCategories() is an array.... how to check(what debugging code is used) whether there is any value or in that function(or array) or it is null....? thanks karthikanov24
  7. hi I tried to find the urls relating to the questions that i posted above by typing , "<td width=\"$columnWidth%\" align=\"center\"><a href=\"" . $_SERVER['PHP_SELF'] . "?c=$catId&p=$pd_id" . "\"> in the google search bar in google website...... but i did'nt get the correct url that explains me these things told by you.. So could you say me,what words should be typed in google search,to get the correct urls that deals with my above question....please...?? and thanks for your answers.. karthikanov24
  8. hi in the following part of the above posted code, <a href=\''".$_SERVER'PHP_SELF']."?=$catId&p=$pd_id". "\"> If the double quotes are replaced by single quotes as follows,its not working... <a href=\'' ' .$_SERVER'PHP_SELF'].'?=$catId&p=$pd_id'. '\"> or <a href=\' ".$_SERVER'PHP_SELF']."?=$catId&p=$pd_id". "\'> or <a href=\' ' .$_SERVER'PHP_SELF'].'?=$catId&p=$pd_id'. '\'> why it so...? could you explain me with an example <a href> tag...please.. thanks karthikanov24
  9. hi <?php echo "<td width=\"$columnWidth%\" align=\"center\"><a href=\"" . $_SERVER['PHP_SELF'] . "?c=$catId&p=$pd_id" . "\"><img src=\"$pd_thumbnail\" border=\"0\"><br>$pd_name</a><br>Price : $pd_price"; ?> In the above line of php code, whats the function of those slashes (\) ..? why the slash is inside the double quotes,which is after c=$catID&p=$pd_id". thanks karthikanov24
  10. hi From where the global variable, $shopconfig which is inside the function displayAmount() gets the reference(value)..? Is it from the variable $shopconfig inside the config.php file or from the variable $shopconfig inside the function (which is above the function displayAmount()) getshopconfig() in common.php file...? thanks karthikanov24
  11. hi In the config file of my application,i have the following code, <?php require_once 'database.php'; require_once 'common.php'; // get the shop configuration ( name, addres, etc ), all page need it $shopConfig = getShopConfig(); ?> In the common.php file,i have the following codes: <?php require_once 'config.php'; require_once 'database.php'; function getShopConfig() { // get current configuration $sql = "SELECT sc_name, sc_address, sc_phone, sc_email, sc_shipping_cost, sc_order_email, cy_symbol FROM tbl_shop_config sc, tbl_currency cy WHERE sc_currency = cy_id"; $result = dbQuery($sql); $row = dbFetchAssoc($result); if ($row) { extract($row); $shopConfig = array('name' => $sc_name, 'address' => $sc_address, 'phone' => $sc_phone, 'email' => $sc_email, 'sendOrderEmail' => $sc_order_email, 'shippingCost' => $sc_shipping_cost, 'currency' => $cy_symbol); } else { $shopConfig = array('name' => '', 'address' => '', 'phone' => '', 'email' => '', 'sendOrderEmail' => '', 'shippingCost' => '', 'currency' => ''); } return $shopConfig; } function displayAmount($amount) { global $shopConfig; return $shopConfig['currency'] . number_format($amount); } Here inside the funtion displayAmount(),why $shopconfig is declared as global?whats the use of it..? thanks karthikanov24
  12. hi foreach() works only for array... Here whether $_POST is array?...if so where is it initialised as array.....? thanks karthikanov24
  13. hi what is the use of addslahes here... thanks karthikanov24
  14. hi This code is about configuration... Could you explain the following codes... if (!get_magic_quotes_gpc()) { if (isset($_POST)) { foreach ($_POST as $key => $value) { $_POST[$key] = trim(addslashes($value)); } } if (isset($_GET)) { foreach ($_GET as $key => $value) { $_GET[$key] = trim(addslashes($value)); } } } thanks karthikanov24
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.