navigating arrays
Posted: Fri Aug 10, 2012 5:00 pm
Hey guys, I'm new to the form but have been watching the Better php vids on Youtube for a while now and love them...
First big stump that I cant really find anything on that makes sense to me... maybe someone here can help.
I'm working with an array with nested arrays
something like this:
the problem I'm running into is when I'm ready to edit info and UPDATE it in mysql -
I have access to the array and know the "id" number of the property I want to change... but I can't figure out how to tell php that I want to find the array with the id = 2, then grab the parent array[1] in this case, and use that array to display what i'll be editing...
what I have now is just taking the id number and subtracting it by 1 to get the array number... this works until you start to delete rows and the array and id's no longer match up.
Any thoughts??? need more info??
Thanks!
Adam
First big stump that I cant really find anything on that makes sense to me... maybe someone here can help.
I'm working with an array with nested arrays
something like this:
[0] => Array ( [id] => 1 [add] => 4247 DALLAs [city] => Dallas [state] => Texas [zip] => 75216 [tenate] => open [owner] => Tester [photo] => /4247_Idaho/images/ [aqu_date] => 2012-08-09 11:08:08 ) [1] => Array ( [id] => 2 [add] => 7621 McCommas [city] => Dallas [state] => Texas [zip] => 75252 [tenate] => open [owner] => Tester [photo] => /7621_Mccallum/images/ [aqu_date] => 2012-08-09 12:41:16 )this info is coming from a mysql db and I'm displaying it onto the page using a foreach loop...
the problem I'm running into is when I'm ready to edit info and UPDATE it in mysql -
I have access to the array and know the "id" number of the property I want to change... but I can't figure out how to tell php that I want to find the array with the id = 2, then grab the parent array[1] in this case, and use that array to display what i'll be editing...
what I have now is just taking the id number and subtracting it by 1 to get the array number... this works until you start to delete rows and the array and id's no longer match up.
Any thoughts??? need more info??
Thanks!
Adam