UPDATE IN PERL WITH MYSQL DATABASE --- CODING
MAKE CHANGES IN THE USR NAME PASSWORD AND DATABASE NAME
update..:
use DBI;
use DBD::mysql;
$platform = "mysql";
$database = "testdb007";
$host = "localhost";
$port = "3306";
$tablename = "Writers";
$user = "2910007";
$pw = "cse007";
#DATA SOURCE NAME
$dsn =
"dbi:mysql:$database:localhost:3306";
# PERL DBI CONNECT
$connect = DBI->connect($dsn, $user,
$pw);
print "\n sucessfully
connected\n";
print"\nEnter new name and ID u
want to change";
$name=<>;
$id=<>;
$query = "UPDATE Writers SET
name='$name' WHERE id='$id'";
# PREPARE THE QUERY
$query1="select * from Writers
ORDER by Id";
$query_handle =
$connect->prepare($query);
$query_handle1 =
$connect->prepare($query1);
# EXECUTE THE QUERY
$query_handle->execute();
$query_handle1->execute();
# BIND TABLE COLUMNS TO VARIABLES
$query_handle1->bind_columns(undef,
\$Id, \$Name);
# LOOP THROUGH RESULTS
print "ID \t NAME\n " ;
while($query_handle1->fetch())
{
print " $Id \t $Name \n>";
}
No comments:
Post a Comment