hi
Code: 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
Login Control?!
I have a Web Site that uses the login control also I have set the destinationurl to the page I want to go to when logged in.
need help with this contact form
I made this form and I need it to read the data and write the data to a table and its not working can someone please help me and show me what I have wrong so I can fix it heres the html form I left
mysqli_fetch_assoc returns multiple arrays, how to return a single array
Hello, I am using mysqli_fetch_assoc which is returning multiple rows, so it looks like:Code: [Select]while($row = mysqli_fetch_assoc($result)) { print_r($row);}But this returns multiple arrays
Php - mysql select?
hi, i have this code:Code: <?phpsession_start();// dBase fileinclude "config.php";if ($_GET["op"] == "login") { if (!$_POST["username"] ||
Notice Undefined index: reset/ Attempting to redirect, works, but get a notice
Full Header.php is:Code: [Select]<?php$reset= false;$reset= strip_tags($_GET["reset"]); //THIS IS LINE 3if(empty($reset)) $reset = false;if($reset==NULL)
how to load a Sys file with system load and call images?
normally you need register the module as a service with CreateService, and start the service
Binding 2 UDP sockets on same port, connected to different destinations, 1 receives
Hello,
Array question
Does anyone know how to create a program that takes the $ amount for 8 different departments and give the total amount of sales?
multipart emiail forms
Hi All, I am new to the boards and I've been working on a form (which is rather massive, imo) and i've been looking online at other peoples php examples for multipart emails. The code i am using /
Php - mysql store data and use it later?
Hi, i' making a login page at the moment, however my username + password is stored many different places, and is kinda hard to get, so I have written this entire code:Code: