// page information $page_type = "t"; $page_title = "Delete Records Perl Database Program"; $page_keywords = "perl, database, mysql, sql, program, code, delete records, sub routine, functions,"; $page_description = "Perl database program deleting records tutorial. Find more tutorials and scripts at TheScripts.com, a programming and software development resource, directory and community."; $page_articletitle = "Deleting Records"; $page_next_url = "/serversidescripting/perl/tutorials/asimpledatabaseprogram/page11.html"; $page_next_anchor = "Deleting Records Part 2"; $page_prev_url = "/serversidescripting/perl/tutorials/asimpledatabaseprogram/page9.html"; $page_prev_anchor = "Display Search Results"; $page_author = "Blair Ireland"; $page_byline = "Senior Editor, TheScripts.com"; // site header include ($_SERVER["DOCUMENT_ROOT"]."/header.php"); // begin html ?>
Our first stop in deleting records is in that sea of ifs near the start of the program.
elsif ($form{'action'} eq "delete") {
&delete_record;
}
As you can see, any time the form variable 'action' is equal to 'delete', you go to the sub &delete_ record;
sub delete_record {
&header("Search To Delete");
Here is a call to &header, feeding in the title
&search_form("delete_two","To Delete");
Ah, here is that sub search_form again. Its use is similar to when we were just searching before, as the first value being sent is the value of the form field 'action'. One difference though, unlike before, we are sending a second value to &search_form. In that sub, it takes that second value and calls it $text. Its only real use is to help the user know what they are doing... as it announces it is 'Searching To Delete' now, instead of just 'Searching'
&footer;
}
The footer is printed, and end of sub procedure.
As the value sent to &search_form for the next action field is 'delete_two', we have to look for that parameter in the 'sea of ifs' again.
elsif ($form{'action'} eq "delete_two") {
&delete_two;
}
So &delete_two is being called now... time to have a look
sub delete_two {
my (@results) = &search;
$search_num = @results;
if ($search_num < 1) { &nomatches; }
All of the above is the same as search_two.... the values being passed, the search occuring, the number of records found and returned.... and if there are less then one then you go straight to sub &nomatches.
elsif ($search_num > 0) {
&multi_match("checkbox","delete_three","Delete",@results);
}
}