473,508 Members | 2,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ


Deleting Records Part 2

By Blair Ireland
Senior Editor, TheScripts.com

Though it may look similar to search_two, this bit is completely different. It calls a sub procedure called &multimatch, and is passing into it three string values, and the array @results where the search results reside. Lets have a look at that sub procedure below.

 

 

sub multi_match {
    my ($type,$action,$what,@results) = @_;

We sent this sub 3 string values, and then an array, so we have to grab them in the order we sent them. @_ is the empty array that is filled whenever you sent a procedure anything.

     my (%rec);

The hash %rec is declared as a my variable.

    &header($search_num." Matches Found For ". $form{'search_term'});

This line is pretty much the exact same as you would find it in sub multi_match_view

    print qq~
    <CENTER><FORM METHOD=POST>
    <INPUT TYPE="hidden" name="action" value="$action">

Here that variable we sent into the procedure, $action, is used as the value for the input field 'action',

    <TABLE border=1 bgcolor="#FFFFFF" cellpadding=3 cellspacing=0>
        <TR bgcolor="#C0C0C0">
        <TD><CENTER><FONT size=-1>Select</CENTER></TD>
    ~;

Since we want to be able to select items to delete, this part adds an extra <TD> for us.

    foreach $field (@db_fields) {
    print qq~<TD><CENTER><FONT size=-1>$field</CENTER></TD>~;
    }

Just like in &multi_match_view, this highlights the name of each field in the procedure

    print qq~</TR>~;
    foreach $result (@results) {
            %rec = &process_record(&grab_data($result));
            print qq~<TR bgcolor="#DDDDDD">
            <TD><INPUT TYPE="$type" 
            NAME="key" value="$rec{$db_key}"></TD>~;
                foreach $field (@db_fields) {
                    print qq~<TD>
                    <FONT size=-1>~.&nl2br($rec{$field}).qq~</TD>~;
                }
            print qq~</TR>~;

This bit is nearly the same as in multi_match_view again, except, this part adds another <TD>. In this TD is an input type, defined by the variable $type sent into the procedure. In the delete case, this is checkbox. The input name is key, and the value is the value the key being used for all records. This re-iterates over each search result.

    }
    print qq~</TABLE><p><INPUT TYPE="submit" 
    value="$what Record(s)"></FORM></CENTER>~;
    &footer;

Here we use $what in the submit button. It just specifies whether you are editing or deleting records. After that, &footer is called again and the footer of the page is printed.

}

« Deleting Records Deleting Records Part 3 »

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.