[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: DATABASE on RH
- From: "Anthony E. Greene" <agreene pobox com>
- To: redhat-list redhat com
- Subject: Re: DATABASE on RH
- Date: Sat, 2 Jan 1999 01:14:28 +0100 (CET)
On Fri, 1 Jan 1999, John Lewis wrote:
>I do have a more complex project lurking though, it involves entering
>competitors names into a database, sorting by race category and allocating race
>numbers according to category. Prior to each race we need to seed riders based
>on previous race history to get an initial start order. Having done that on race
>day we need to be able to automatically log race times to each rider and then
>sort results and reallocate start
>order for the second run. Finally we need to be able to get an instant printout
>of the results.
A web/database could do this easily. The input would be best done from a
browser that allows you to [Tab] from the last field to the "Submit"
button and press [Enter] or [Space] to submit the form data. My regular
Win95 browser (Opera) allows this.
Another option would be an ncurses application run via telnet. This would
be much more complex to write though.
Depending on the table structures and sizes, you could enter the data
using the browse table in pgaccess. It looks somewhat like a spreadsheet
with regards viewing and editing data. I lean toward the web/database
interface because it's more easily customized.
This is a complex enough application that you'll have to do some coding to
make it fast and easy to use. I can't see using a generic GUI interface to
do it. An advantage to using a web-based postgreSQL solution is that it's
inherently multi-user. So you can have as many people managing the data
simultaneously as you have PC's available.
>$75 and I'd give it a try, if it has a graphical interface to set up forms,
>reports etc, but $750 is over the top these days.
Simple HTML forms are almost trivial. For instance a form for adding data
to an address book might look like:
<html>
<head><title>New Address Book Entry</title></head>
<body bgcolor="white">
<h1>New Address Book Entry</h1>
<form method="PUT" action="http://linuxbox.domain/cgi-bin/newentry.pl">
<table>
<tr><td align=right>Name:<td><input name="name" type="text" size=40>
<tr><td align=right>Street:<td><input name="street" type="text" size=40>
<tr><td align=right>City:<td><input name="city" type="text" size=40>
<tr><td align=right>Phone:<td><input name="phone" type="text" size=15>
<tr><td></td><td><input type="submit" name="submit" value="Submit">
<input type="reset" name="reset" value="Reset">
</table>
</form>
</body>
</html>
The script to accept the input and add the record to the database might
look like this:
#!/usr/bin/perl
#
# Use the CGI and postgreSQL modules
use CGI;
use Pg;
# Get the form data
$query = new CGI;
$qname = param("name");
$qstreet = param("street");
$qcity = param("city");
$qphone = param("phone");
# Connect to the database
$conn = Pg::connectdb("dbname=addrbook user=nobody");
# Construct the query
$sql = "INSERT INTO addrbook (name,street,city,phone)";
$sql = $sql . " VALUES ('$qname','$qstreet','$qcity','$qphone')";
# Insert the data into the db
$result = $conn->exec($sql);
# Send an acknowledgement back to the browser
print "Content-type: text/html\n\n";
print "<html><h3>Form data received</h3></html>";
# End of script
I left out all error checking for brevity. This code has not been tested.
I'm using code from existing scripts as an example, but I have not
actually run this code. I expect it would work though. I also did not
include any provisions for security. There are several ways to handle
that. I generally use basic HTTP authentication in the forms and CGI
directories and get the username like this:
$quser = $query->remote_user();
The database connection would then look like:
$conn = Pg::connectdb("dbname=addrbook user=$quser");
You could put links across the top or bottom of the input form to access
other forms or CGI scripts. For instance, one link could run a script that
generates the results as an HTML table and returns them to the browser for
viewing and printing. Or the table could be generated as plain text and
sent directly to a printer that's accessible from the Linux box.
If you needed fancier layout than HTML can provide, you could generate the
results as RTF and view/print them with MS Word.
The hardest part I see is getting the data from the sensors into the
database.
--
Anthony E. Greene <agreene pobox com>
Homepage & PGP Key <http://www.pobox.com/~agreene/>
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]