myitalan Posted July 22, 2012 Share Posted July 22, 2012 Greetings, I am trying to delete a record from my xml file. The display is correct with the delete button but it not delete. Any help. <html> <head></head> <body> <?php $xmldoc = new DOMDocument(); $xmldoc->load('gallery.xml', LIBXML_NOBLANKS); $count = 0; $activities = $xmldoc->firstChild->firstChild; //prints the list of activities, with checkboxes on the left for each item //the $count variable is the id to each entry if($activities!=null){ echo '<form name=\'erase\' action=\'delete.php\' method=\'post\'>' . "\n"; while($activities!=null){ $count++; echo " <input type=\"checkbox\" name=\"activity[]\" value=\"$count\"/>"; echo ' '.$activities->textContent.'<br/>'."\n"; $activities = $activities->nextSibling; } echo ' <input type=\'submit\' value=\'erase selected\'>'; echo '</form>'; } ?> //section used for inserting new entries. this feature is working as expected. <form name='input' action='idelete.php' method='post'> insert activity: <input type='text name='activity'/> <input type='submit' value='send'/> <br/> </form> </body> </html> delete.php <?php $xmldoc = new DOMDocument(); $xmldoc->load('sample.xml', LIBXML_NOBLANKS); $atvID = $_POST['activity']; foreach($atvID as $id){ $delnode = $xmldoc->getElementsByTagName('activity'); $xmldoc->firstChild->removeChild($delnode->item($id)); } $xmldoc->save('gallery.xml'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/266067-display-image-instead-of-image-file-name/ Share on other sites More sharing options...
requinix Posted July 22, 2012 Share Posted July 22, 2012 You have two different ways of coming up with activities (counting nodes versus a search on //activity), which isn't all that surprising since you're using two different XML files. What's up with that? [edit] And what does any of this have to do with "display image instead of image file name"? Quote Link to comment https://forums.phpfreaks.com/topic/266067-display-image-instead-of-image-file-name/#findComment-1363406 Share on other sites More sharing options...
myitalan Posted July 22, 2012 Author Share Posted July 22, 2012 Greetings, My apologies, the subject was for a post that i was going to send, however I figured that out and placed this post forgetting to change the subj. The First Code listing is the load form from my xml file... not posted. and the second is the delete.php file. the xml looks like this: <list> <activity>swimming</activity> <activity>running</activity> <activity>soccer</activity> </list> [code] Any help would be fine. I just want to delete the entries from the check box. ALso, I thank you for replying... if you find yourself unable to assist me any further without solving, please let me know so I could move on to a different strategy. I know you're communication with many others... I just want to finish this 4 day journey of just displaying data from man xml file and edit and deleting them. I've got the adding down. Quote Link to comment https://forums.phpfreaks.com/topic/266067-display-image-instead-of-image-file-name/#findComment-1363417 Share on other sites More sharing options...
heidelberg77 Posted July 22, 2012 Share Posted July 22, 2012 In "delete.php" you do open "sample.xml" but you are saving the result to "gallery.xml"...Is this what you expect? Quote Link to comment https://forums.phpfreaks.com/topic/266067-display-image-instead-of-image-file-name/#findComment-1363450 Share on other sites More sharing options...
myitalan Posted July 22, 2012 Author Share Posted July 22, 2012 Greetings, No... That was my error during the cut and past and retype. With the correct file called it still doesn't delete. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/266067-display-image-instead-of-image-file-name/#findComment-1363510 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.