how to increment character value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • unlawfulpub
    New Member
    • Dec 2006
    • 3

    how to increment character value

    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
  • GunnarH
    New Member
    • Nov 2006
    • 83

    #2
    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.

    Comment

    • unlawfulpub
      New Member
      • Dec 2006
      • 3

      #3
      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:m ysql:dbname,use r, pass);
      #prepare and execute SQL statement
      $sqlstatement=" SELECT reg_id, category_id, category_name FROM table1 where category_id = \'$category_id\ ' ";
      $sth = $dbh->prepare($sqlst atement);
      $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>Catego ry ID</b></td>";
      print "<td><p align=\"center\ "><b>Catego ry 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

      Comment

      • docsnyder
        New Member
        • Dec 2006
        • 88

        #4
        Do you mean something like this???

        Code:
        for ( $i=26, $c='a' ; $i ; $i--, $c=chr(ord($c)+1) ) { printf("$c\n"); }
        Greetz, Doc

        Comment

        Working...