From: wbudic Date: Tue, 21 Aug 2018 10:35:45 +0000 (+1000) Subject: Modified select and andded del form, no cgi file for deletion yet. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=ed819069a77a9c3d7bb8814dc51f627716c0cc63;p=LifeLog.git Modified select and andded del form, no cgi file for deletion yet. --- diff --git a/htdocs/cgi-bin/.main.cgi.swo b/htdocs/cgi-bin/.main.cgi.swo deleted file mode 100644 index 2dcb35b..0000000 Binary files a/htdocs/cgi-bin/.main.cgi.swo and /dev/null differ diff --git a/htdocs/cgi-bin/.main.cgi.swp b/htdocs/cgi-bin/.main.cgi.swp deleted file mode 100644 index f15b2e0..0000000 Binary files a/htdocs/cgi-bin/.main.cgi.swp and /dev/null differ diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 4588661..365faa8 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -41,10 +41,9 @@ if(!$sth->fetchrow_array()) { my $stmt = qq( CREATE TABLE LOG ( - ID INT PRIMARY KEY NOT NULL, - ID_CAT TINY, + ID_CAT TINY NOT NULL, DATE DATETIME NOT NULL, - LOG VCHAR(60) + LOG VCHAR(60) NOT NULL ); ); @@ -55,9 +54,9 @@ if(!$sth->fetchrow_array()) { print "

Error->"& $DBI::errstri &"

"; } - $sth = $dbh->prepare('INSERT INTO LOG VALUES (?,?,?,?)'); + $sth = $dbh->prepare('INSERT INTO LOG VALUES (?,?,?)'); - $sth->execute(1, 3, $today, "DB Created!"); + $sth->execute( 3, $today, "DB Created!"); $stmt = qq( @@ -85,7 +84,7 @@ if(!$sth->fetchrow_array()) { $sth->execute(32, "Expense"); } my $stmtCat = "SELECT * FROM CAT;"; -my $stmt = "SELECT * from LOG;"; +my $stmt = "SELECT rowid, ID_CAT, DATE, LOG from LOG ORDER BY rowid DESC, DATE DESC;"; $sth = $dbh->prepare( $stmtCat ); @@ -95,14 +94,14 @@ my $cats = ''; -my $tbl = ''; +my $tbl = '
DateTimeLogCategory
'; my $tbl_rc = 0; ################################## @@ -126,19 +125,21 @@ if($rv < 0) { $tbl = $tbl . "" . "" . "". - "\n"; + "\n"; $tbl_rc +=1; } if($tbl_rc==1){ - $tbl = $tbl . "\n"; + $tbl = $tbl . "\n"; } - $tbl = $tbl . "
DateTimeLogCategoryDel
". $dt->ymd . "" . $dt->hms . "" . $row[3] . "" . $ct ."
" . $ct . + "
Table is Empty!
Table is Empty!
"; + $tbl = $tbl . ""; + $tbl = $tbl . ""; my $frm = qq(
- + @@ -149,9 +150,8 @@ my $frm = qq( -print "
\n" . $tbl ."
"; print "
\n" . $frm ."
"; - +print "
\n" . $tbl ."
"; print $q->end_html; $dbh->disconnect(); @@ -163,17 +163,23 @@ sub processSubmit { my $log = $q->param('log'); my $cat = $q->param('cat'); + if($log && $date && $cat){ + #check for double entry + # + + my $sth = $dbh->prepare( + "SELECT DATE,LOG FROM LOG where DATE='".$date ."' AND LOG='".$log."';" + ); - if($log){ - print "

Received!". $log. "

"; - - } - if($date){ - print "

Received!". $date. "

"; + $sth->execute(); + if(my @row = $sth->fetchrow_array()){ + return; + } - } - if($cat){ - print "

Received!". $hshCats{$cat}. "

"; + + $sth = $dbh->prepare('INSERT INTO LOG VALUES (?,?,?)'); + $sth->execute( $cat, $date, $log); + } }
DateDatehms . qq(">
Log: ).$cats.qq(