Jan G.B. wrote: > 2009/5/12 PJ <af.gourmet@xxxxxxxxxxxx>: > >> Could somebody please explain this? >> When the line - sort($category) is commented out, the output returns >> Notice: Undefined offset: in the line "36" for all the repeats (29 in >> this case) >> > > Sure thing if you consider this: > > > > >> The code below: >> <? >> $SQL = "SELECT name >> FROM categories ORDER BY category_id >> "; >> $category = array(); >> //[...] >> $category[$row['name']] = $row; >> //[...] while >> $cat = $category[$ii]['name']; //=======this is line 36========== >> >> > > After setting only $arr[NAMEfromDB], why should be a numeric index $arr[INT] ? > > > Now just do var_dump($category) before and after your sort() - But I > don't see why you still have it, when the query itself does the > sorting. > > Regards > Kind of a nice solution for the problem I originally had which was to use a list of categories in the db which had to be used in href for pages with the same names. I had to sort the list as, at the time, I did not know how otherwise to sort the list - the id field was not sequential and I don't remember what other problem may have been involved. I had forgotten that the sort changed the keys. Actually, in the present case I did not want to sort by id since it was already sorted the way I wanted. Thanks to all for the input. The haze slowly clears... :-) -- Hervé Kempf: "Pour sauver la planète, sortez du capitalisme." ------------------------------------------------------------- Phil Jourdan --- pj@xxxxxxxxxxxxx http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php