Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: mysql update table how to

by poj (Abbot)
on Mar 17, 2019 at 13:57 UTC ( [id://1231358]=note: print w/replies, xml ) Need Help??


in reply to mysql update table how to

Only select the records you want to update

#!/usr/bin/perl use strict; use warnings; use DBI; my $userid = DB::trim( param('Userid') ); # ?? my $username = DB::trim( param('Username') ); my $password = DB::trim( param('Password') ); my $DISABLED = ucfirst ( DB::trim( param('Disabled') ) || '' ); $DISABLED = 'No' unless $DISABLED eq 'Yes'; my $sql = 'SELECT ID,DISABLED FROM EmployerJobs WHERE Username = ? AND UserPassword = ? AND Userid = ? AND Disabled <> ?'; my $dbh = DB::connect(); my $tbl_info = DB::TableInfo->get ($dbh, "EmployerJobs"); my $sth = $dbh->prepare($sql); $sth->execute($username, $password, $userid, $DISABLED); param (-name => "Disabled", -value => $DISABLED); while ( my $row = $sth->fetchrow_hashref() ){ param (-name => "ID", -value => $row->{ID}); $tbl_info->update_record ($dbh, "ID"); printf "Updated ID '%s' from '%s' to '%s'\n",$row->{ID},$row->{DISAB +LED},$DISABLED; };
poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1231358]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2024-04-20 06:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found