Help for this page

Select Code to Download


  1. or download this
    # issue query
    my $sth = $dbh -> prepare("SELECT uid, fname, lname FROM users") || &b
    +ail_out("Error: cannot prepare DB query");
    $sth -> execute() || &bail_out("Error: cannot execute DB query");
    
  2. or download this
    while (@rray = $sth -> fetchrow_array) {
        $row{uid} = $rray[0];
    ...
    foreach (@rows) {
        print "$_\n";
    }
    
  3. or download this
    while (@rray = $sth -> fetchrow_array) {
        $record = "record_$i";
    ...
    while (($key, $value) = each(%hash)) {
        print "key = $key, value = $value\n";
    }
    
  4. or download this
    while (@rray = $sth -> fetchrow_array) {
        $record = "record_$i";
    ...
    while (($key, $value) = each(%hash2)) {
        print $hash2{$value} -> {fname};
    }