Can anyone provide me the Code for deleting 50 nodes at a time in drupal software.I would really appreciate that person.
Can anyone provide me the Code for deleting 50 nodes at a time in drupal software.I would really appreciate that person.
In this example i am going to delete all nodes of a particular type (page), a quick way to execute the code is to create a new node, set the input format to PHP, paste the code into the node body - add a title and click submit -
<?php
$node_type = 'page';
//fetch the nodes we want to delete
$result = db_query("SELECT nid FROM {node} WHERE type='%s'",$node_type);
while ($row = db_fetch_object($result)){
node_delete($row->nid);
$deleted_count+=1;
}
//simple debug message so we can see what had been deleted.
drupal_set_message('$deleted_count nodes have been deleted');
?>
Note:- Don't forget to delete the node when your done.
Thanks a lot it worked for me
Bookmarks