hbradshaw has asked for the wisdom of the Perl Monks concerning the following question:

Good Evening Monks!

I'm writing a simple To-Do application in a way to learn Perl. The database table consists of three fields: time, status, and content.

I want to be able to see my items and to update a particular item at the same time. I am having trouble with the update portion of the script.

You can view the code in my scratchpad.

The script initially calls for subroutine show_item() which shows the item information. This subroutine shows two different methods of updating the item.

The first: submit (-name => "choice", -value => "Update") - applies the update to all the items, doesn't post to the database table and when you refresh the page the original information prior to the update appears. The update never occurred.

The second: " [", a ({-href => update_url}, "Update"), "]", doesn't apply the update and removes any information associated with that item except for the time. The update never occurred.

Here are the areas of the script that has update coded:

elsif ($choice eq "update") sub update_item sub show_item
Any guidance or advice you can give will be greatly appreciated.

Thanks.

Replies are listed 'Best First'.
Re: Problem with an update subroutine
by Coruscate (Sexton) on Jan 15, 2003 at 08:34 UTC

    You can view the code in my scratchpad.

    Yes, I was able to do that. After clicking on your username, then on 'View Scratchpad'. I have two bones to pick with the use of 'look at my scratchpad' in posts: to begin with, I had to leave the current page to go look at the code. It took 2 clicks. Second of all, I fail to believe that your scratchpad is going to remain static. Once you remove that code from your scratchpad, users that come along this post later on will not have a chance to examine your code. This post will become more or less useless.

    So what solution would satisfy me (since that's what I, as an internet user, demand :P) for this post and other posts in the future: use the <readmore> tags provided on this site. In this way, I won't have to leave the thread to look at the code, and I know that the code will not be removed at any time (unless the horrible NodeReaper I've been hearing about lately happens to not like your post. That NodeReaper seems like one scary dude...).

Re: Problem with an update subroutine
by tall_man (Parson) on Jan 15, 2003 at 01:09 UTC
    Most of your example appears to be copied verbatum from example script from the textbook "MySQL and Perl for the Web" on this page. I think you ought to give credit to the source, and tell us what you modified from the working examples.