
Rab
Deleted
Aug 3, 2000, 3:32 AM
Post #1 of 2
(607 views)
|
Displaying selected data from dbase
|
Can't Post
|
|
Hi Experts.... I am pulling info from a dbase by month -- no probs there The results are displayed in a table with a check-box at the end of the row to give the user an option to add selected entries to another dbase. If I omit the check-boxes all works fine...but I'm struggling when I do include them ...... sample code ..... #!/usr/bin/perl print "Content-type:text/html\n\n"; print "<html><head><title>Update E-mail Dbase</title></head>\n"; print "<body>\n"; $tickedcount = 0; $filename = "db"; # email database variable $emaildb = "email.dat"; # empty the temp email dbase before writing to it &cleardb; open(INF,$filename) | | die "Can't open the database : $!"; @indata = <INF>; close(INF); foreach $i (@indata) { chop($i); ($password,$date,$inact,$companyname,$date2,$companyname,$inact1,$inact2, $description,$postcodes,$address,$country,$phone,$phone2,$email,$url) = split(/\_/,$i); ($recordid) = split(/\|/,$i); $snapcounttotal++; # this formats date from 2000/07/25 to 25/07/2000 in table at bottom ($snapyear, $snapmonth, $snapday) = split (/\//, $date); ### display by selected month ########## if ($snapmonth =~ /01/ig) { ####### check-box code ###### read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } @checked = ("selected"); foreach $x (@checked) { if ($FORM{$x} == 1) { $tickedcount++; &add_email; print "u picked $x!\n"; } die; } ###### end check box code ### } } print "<HTML><HEAD></HEAD><BODY BGCOLOR=\"C0C0C0\">"; print "<h4 align='center'>Confirmed ! - $tickedcount entries above have been added to the E-mail database </h4>"; ############## sub-routines ########################################## sub add_email { open (FILE,">>$emaildb") | | die "cannot open e-mail file :$!"; print FILE "$email\n"; } sub cleardb { open (FILE,">$emaildb") | | die "cannot open e-mail file :$!"; print FILE ""; } ########### end sub-routines ######################################## If I tick any of the boxes I get ALL the entries being added not the required Selected (ticked) ones ...... What am I missing guys ! Mike
|