Connecting Tech Pros Worldwide Help | Site Map

how to increment character value

Newbie
 
Join Date: Dec 2006
Posts: 3
#1: Dec 17 '06
Sorry guys just wanted to learn. I have a database. When I do the search using mysql suppose i have 100 records I wanted to keep the first second ... in the loop to be retrain.
like an integer you may use $count = $count + 1;
then in the second round count value would be 2.
In this case I wanted the character to retain the old value incrementally
ex. first loop. kind = a
second. kind = a , b
3rd. kind = a , b c and so on

thanks. I need your help. thanks a lot
Member
 
Join Date: Nov 2006
Posts: 83
#2: Dec 17 '06

re: how to increment character value


I for one don't understand what you are talking about. Maybe it is because English isn't my first lanuage...

You may want to try talking Perl instead of English, i.e. show us the code you have prepared in an attempt to do whatever you are trying to do.
Newbie
 
Join Date: Dec 2006
Posts: 3
#3: Dec 17 '06

re: how to increment character value


Quote:

Originally Posted by GunnarH

I for one don't understand what you are talking about. Maybe it is because English isn't my first lanuage...

You may want to try talking Perl instead of English, i.e. show us the code you have prepared in an attempt to do whatever you are trying to do.

-

$dbh = DBI->connect('dbi:mysql:dbname,user, pass);
#prepare and execute SQL statement
$sqlstatement="SELECT reg_id, category_id, category_name FROM table1 where category_id = \'$category_id\' ";
$sth = $dbh->prepare($sqlstatement);
$sth->execute ||
die "Could not execute SQL statement ... maybe invalid?";

print "<table border = 0>";
print "<td><p align=\"center\"><b>Reg ID</b></td>";
print "<td><p align=\"center\"><b>Category ID</b></td>";
print "<td><p align=\"center\"><b>Category Name</b></td>";
print "<tr>";
#output database results
while (@row=$sth->fetchrow_array)
{

my $query = "UPDATE table2 set category_name = \"$row[2]\" where reg_id = \"$row[0]\" ";



}

table1 having 100 records
the category_name under table2 are empty I wanted to fill this empty column with the value table1 under category_name would be placed using the condition of reg_id both table have same common entry.

Thanks
docsnyder's Avatar
Member
 
Join Date: Dec 2006
Location: Darmstadt
Posts: 88
#4: Dec 19 '06

re: how to increment character value


Do you mean something like this???

Expand|Select|Wrap|Line Numbers
  1. for ( $i=26, $c='a' ; $i ; $i--, $c=chr(ord($c)+1) ) { printf("$c\n"); }
Greetz, Doc
Reply


Similar Perl bytes