Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
I don't know any Java, but if you want to give it a try, here's the code I used for the script.
#!/usr/bin/perl -w use DBI; use strict; # Create a new Apache request object my $r = shift; # Set up the parameter hash my %q = $r->method eq "GET" ? $r->args : $r->content; my $dbh = DBI->connect("DBI:mysql:adressen", "user", "secret", {RaiseE +rror => 1}); $r->send_http_header; print qq(<html> <head> <title>Adressbuch</title> </head> <body bgcolor="#ffffff"> ); print qq( <CENTER> <H1>Mein Adressbuch</H1> <A>Neuer Eintrag</A><BR><BR> <B>Suche nach:</B><BR> <FORM METHOD="POST"> <INPUT TYPE=text NAME=list SIZE=30> <INPUT TYPE=submit VALUE="Suche"> </FORM> <P> ); for ('A' .. 'Z') { print "<a href=\"/perl/adressen/?list=$_\">$_</a>&nbsp;\n"; } print "<br><br>\n"; if ($q{"list"}) { my $search = $q{list}; my $sth = $dbh->prepare("SELECT * FROM list WHERE nachname LIKE ? +ORDER BY nachname"); $sth->execute("$search%"); my ($nachname, $vorname, $strasse, $plz, $ort, $telefon1, $telefon +2, $email, $id); $sth->bind_columns(\($nachname, $vorname, $strasse, $plz, $ort, $t +elefon1, $telefon2, $email, $id)); if ($sth->rows > 0) { print "<BR><BR>"; print "<H3>Gefundene Einträge:</H3>"; print "<TABLE border=0 cellpadding=5>"; print "<tr align=center><td><b>Name</b></td><td><b>Straße</b>< +/td><td><b>PLZ Ort</b></td><td><b>Telefon</b></td><td><b>eMail</b></t +d></tr>"; while ($sth->fetch) { print "<TR>"; print "<TD valign=top><B>$nachname $vorname</B></TD>"; print "<TD valign=top>$strasse</TD>"; print "<TD valign=top>$plz $ort</TD>"; print "<TD valign=top>$telefon1<BR>"; print "$telefon2</TD>"; print "<TD valign=top><I><A HREF=mailto:$email>$email</A>< +/I>"; print "</TD>"; print "<TD align=right valign=top><FONT SIZE=-1><A HREF=ch$id>&Auml;ndern</A>&nbsp;&nbsp;"; print "<A$id>L&ouml;schen</A></FONT></TD> +</TR>"; print "<TR><TD colspan=7><HR></TD></TR>"; } print "</table>\n"; } else { print "<h3>Nichts gefunden.</h3>\n"; } } print "</center>\n"; print qq( </body> </html> );

In reply to RE: RE: Training wheels again by le
in thread Training wheels again by le

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.