Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > VodaHost Web Hosting Support > mySQL & PHP

Notices

mySQL & PHP Discussions, information and help with mySQL and PHP.

Reply
 
LinkBack Thread Tools
  #1  
Old 06-18-2007, 11:39 PM
Andy128's Avatar
Major General
 
Join Date: Dec 2005
Location: Michigan
Posts: 2,288
Default flat file- delete 1 array of multidimentional array

Lets see if I can explain this. I am able to load elements of a form into a flat file- such as Name, Address, Phone# etc..... Then I load these into a multidimentional array- say $hold, which looks something like this
$hold[1] => array([0]=>1, [1]=>Frank,[2]=>123 St,[3]=>555-5555)
$hold[2] => array([0]=>2, [1]=>Kelly, [2]=>111 St,[3]=>111-1111)
$hold[3] => array([0]=>3, [1]=>Suzie,[2]=>333 St,[3]=>222-2222)

*the element $hold[1][0] = 1 is simply a way to count records which also corresponds to the exact $hold array so that I can edit elements as seen in the table

I then load these into a table.

I can successfully change any specific element but I cannot figure out how to delete say $hold[2].

Any suggestions?

Andy
__________________
My diamond in the rough - www.123gpp.com

* Click here for some BV tutorials (Php mailto Form, I-Frames, Picture display and much, much more!)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 06-19-2007, 12:01 AM
Watdaflip's Avatar
Brigadier General
 
Join Date: Sep 2005
Location: Cincinnati, Ohio
Posts: 1,643
Default Re: flat file- delete 1 array of multidimentional array

The only way that I know of (at least can think of, I never needed to delete an array element, so I haven't looked for a built in solution), but I would

1. find the count - $total_count = count($hold);

2. overwrite the record in the array with the one after it with a loop
for($i=$array_num_to_delete; $i < $total_count; $i++)
{
$hold[$i] = $hold[($i+1)];
}

3. decrement the total
$total_count--;

Then write the new array to the file to save it, and the element is removed.

Note: I just wrote it, so it hasn't been tested, it might not work, if it doesn't ill try to figure something that will work
__________________

Register/Login Script
Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old 06-19-2007, 08:29 PM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 8,997
Default Re: flat file- delete 1 array of multidimentional array

Watdaflips solution is correct, however, you should use the $total_count (after reduction by 1) variable and in your save routine have only the first $total_count elements writen, because with the transfer (from index i+1 to index i ) the last two cells of the array will be the same.

Otherwise, place

$hold[2] = ""; (if the $hold[2] is the one to be deleted)

Then, in the Save routine, place a "if" statement to NOT write into the file whichever $hold[] is empty.
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old 06-20-2007, 06:31 PM
Andy128's Avatar
Major General
 
Join Date: Dec 2005
Location: Michigan
Posts: 2,288
Default Re: flat file- delete 1 array of multidimentional array

Watdaflip and Navaldesign-

Thanks- I will give it a try.

Andy
__________________
My diamond in the rough - www.123gpp.com

* Click here for some BV tutorials (Php mailto Form, I-Frames, Picture display and much, much more!)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 10:32 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2007 VodaHost.com - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54