[Chicago-talk] humbling question
Brian Katzung
briank at kappacs.com
Wed Sep 19 07:15:31 PDT 2007
Hi Richard.
I've suggested some changes and additions below.
- Brian
Richard Reina wrote:
> I am trying to write a simple program like the one below that lets users
> at a console select an active employee. However, because they are not
> supposed to see the employee's employee number I can't figure out a way
> to let them make the selection. I thought I could do it with a counter
> ($i) but don't know of a way to associate the date with the count. Any
> ideas would be greatfully appreciated.
>
> Thanks,
>
> Richard
>
> #!/usr/bin/perl -w
>
> my $q = "SELECT emp_no, first_name, last_name, mobile_ph
> FROM employee
> WHERE end_date IS NULL"
> my $sth->prepare($q);
>
> my ($emp_no, $f_name, $l_name, $ph);
> $sth->execute();
$sth->bind_columns(\$emp_no, \$f_name, \$l_name, \$ph);
>
my $i = 0;
my @emp_no;
> while($sth->fetch) {
$emp_no[$i++] = $emp_no;
> print $i . " " . $name . " " $f_name . " " . $l_name . " " . $ph ."\n";
> }
>
> print "Somehow make a selection based on what you're allowed to view\n";
> my ($sel = <STDIN>);
my $selected_emp_no = $emp_no[$sel - 1];
You'll want to add error checking, use DBI, etc, but that should get you
started.
--
Brian Katzung, Kappa Computer Solutions, LLC
Leveraging UNIX, Linux, open source, and custom
software solutions for business and beyond
Phone: 877.367.8837 x1 http://www.kappacs.com
More information about the Chicago-talk
mailing list