Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] perl/cgi and hyperlinks

Expand Messages
  • Gordon Stewart
    ... Hi all, ... Do you need help Creating the directory / files - Or are they already created, & you need to just created the AHREF tags to get to the files ?
    Message 1 of 8 , Jun 3, 2001
    • 0 Attachment
      --- Franky Claeys <franky_claeys@...> wrote: >
      Hi all,
      >
      > This may be a little bit of a easy problem but I'm
      > not
      > finding the solution
      > (bit of newbie...):
      >
      > In a perl/cgi script I would like to construct
      > something like this rule:
      >
      > print "<li>name <b><a
      > href=names/$in{'username'}.htm></a></b> \n";
      >
      > $in comes from a form-input and in the dir names are
      > all files with possible
      > names (equal to the dynamic form-input).
      > These files need to be dynamically linked (based on
      > the form-input).
      >
      > Anyone any suggestions to solve this issue?
      >
      > Thanks a million times in advace!

      Do you need help Creating the directory / files - Or
      are they already created, & you need to just created
      the AHREF tags to get to the files ?

      Gordon
      gordonistewart_nz Yahoomessenger.





      > greetz from Belgium
      >
      > Frank
      >
      > www.franksite.net
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > __________________________________________________
      > Do You Yahoo!?
      > Get personalized email addresses from Yahoo! Mail -
      > only $35
      > a year! http://personal.mail.yahoo.com/
      >
      >
      >
      > Your use of Yahoo! Groups is subject to
      > http://docs.yahoo.com/info/terms/
      >
      >


      ____________________________________________________________
      Do You Yahoo!?
      Get your free @... address at http://mail.yahoo.co.uk
      or your free @... address at http://mail.yahoo.ie
    • Gordon Stewart
      ... Hi all, ... If you want to just create the A HREF tags, it should be as follows :- print name n ; you
      Message 2 of 8 , Jun 3, 2001
      • 0 Attachment
        --- Franky Claeys <franky_claeys@...> wrote: >


        Hi all,
        >
        > This may be a little bit of a easy problem but I'm
        > not
        > finding the solution
        > (bit of newbie...):
        >
        > In a perl/cgi script I would like to construct
        > something like this rule:

        > print "<li>name <b><a
        > href=names/$in{'username'}.htm></a></b> \n";
        > $in comes from a form-input and in the dir names are
        > all files with possible
        > names (equal to the dynamic form-input).

        If you want to just create the A HREF tags, it should
        be as follows :-

        print "<li>name <b><a
        href=names\/$in{username}.htm><\/a><\/b>\n";

        you need to back-slash the '/' character
        - ie \/

        If you can post the code, so we can see how the $in
        value is created, - we can help further.

        Gordon.



        ____________________________________________________________
        Do You Yahoo!?
        Get your free @... address at http://mail.yahoo.co.uk
        or your free @... address at http://mail.yahoo.ie
      • Charles K. Clarkson
        Gordon Stewart [snip] ... Not in strings. You need to escape / characters in regexes where the forward slash is a delimeter.
        Message 3 of 8 , Jun 3, 2001
        • 0 Attachment
          Gordon Stewart <gordonistewart_nz@...>
          [snip]
          :
          : If you want to just create the A HREF tags, it should
          : be as follows :-
          :
          : print "<li>name <b><a
          : href=names\/$in{username}.htm><\/a><\/b>\n";
          :
          : you need to back-slash the '/' character
          : - ie \/

          Not in strings. You need to escape '/' characters
          in regexes where the forward slash is a delimeter.

          print "<li>name <b>hello<\/b><\/li>\n";
          print "<li>name <b>hello</b></li>\n";

          print the same thing.

          :
          : If you can post the code, so we can see how the $in
          : value is created, - we can help further.
          :

          HTH,
          Charles K. Clarkson


          Reality is that which,
          when you stop believing in it,
          doesn't go away. - Philip K. Dick
        • franky_claeys@yahoo.com
          This is my enteire cgi-script: #!/usr/bin/perl -w use CGI; use DBI; use diagnostics; use Data::Dumper; read(STDIN,$buffer,$ENV{ CONTENT_LENGTH });
          Message 4 of 8 , Jun 3, 2001
          • 0 Attachment
            This is my enteire cgi-script:

            #!/usr/bin/perl -w

            use CGI;
            use DBI;
            use diagnostics;
            use Data::Dumper;


            read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
            @pairs=split(/&/,$buffer);
            foreach $pair(@pairs)
            {
            ($name,$value)=split(/=/,$pair);
            $value=~tr/+//;
            $value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
            $ticker{$name}=$value;
            }

            $dbh=DBI->connect('dbi:mysql:test', 'root', 'anneleen');


            $company=&find_company($ticker{'tick'});

            if ($company eq "notfound")
            {
            print "Content-Type:text/html\n\n";
            print "<html><head></head></html>";
            print "<body><p>help</p></body>";
            }
            else
            {
            &do_for_company($company);
            }


            ###################
            #
            # first subroutine
            #
            ###################

            sub find_company

            {
            $ticker{'tick'}=shift;

            $findcompsql="select comp from ticklist where sym=\"$ticker
            {'tick'}\"";

            $sth2=$dbh->prepare($findcompsql);

            $sth2->execute;

            if
            (@comp_res=$sth2->fetchrow_array)
            {
            $company=$comp_res[0];
            }
            else
            {
            $sth2->finish ();
            return "notfound";
            }
            $sth2->finish ();
            return $company;
            }

            ######################
            #
            # second subroutine
            #
            #####################


            sub do_for_company
            {
            $comp=shift;
            $sql="SELECT max(date) FROM $comp";

            $sth=$dbh->prepare($sql);
            $sth->execute;
            $date= ($sth->fetchrow_array ())[0];
            $sth->finish ();

            $sql2="SELECT * from $comp WHERE date = '$date'";
            $sth=$dbh->prepare($sql2);
            $sth->execute ();
            if (@rows=$sth->fetchrow_array)
            {
            $sym=$rows[0];
            $cname=$rows[1];
            $datum=$rows[2];
            $open=$rows[3];
            $close=$rows[4];
            $high=$rows[5];
            $low=$rows[6];
            $vol=$rows[7];
            $verand=$rows[8];
            print<<"END";
            Content-type:text/html\n\n
            <html>
            <head>
            </head>
            <body>

            [snip html code]

            #I need to make a dynamic link using the input from a html-form
            #The name of the html text field is tick
            #the directory in wich the files are is clinegraphs
            #I have find several solutions in cgi manuals but cannot make it work

            <img src="clinegraphs/\"$ticker{'tick'}.gif\"">


            [snip html code]

            </body>
            </html>
            END
            }
            $sth->finish ();
            }
            $dbh->disconnect;













            --- In perl-beginner@y..., Gordon Stewart <gordonistewart_nz@y...>
            wrote:
            >
            > --- Franky Claeys <franky_claeys@y...> wrote: >
            >
            >
            > Hi all,
            > >
            > > This may be a little bit of a easy problem but I'm
            > > not
            > > finding the solution
            > > (bit of newbie...):
            > >
            > > In a perl/cgi script I would like to construct
            > > something like this rule:
            >
            > > print "<li>name <b><a
            > > href=names/$in{'username'}.htm></a></b> \n";
            > > $in comes from a form-input and in the dir names are
            > > all files with possible
            > > names (equal to the dynamic form-input).
            >
            > If you want to just create the A HREF tags, it should
            > be as follows :-
            >
            > print "<li>name <b><a
            > href=names\/$in{username}.htm><\/a><\/b>\n";
            >
            > you need to back-slash the '/' character
            > - ie \/
            >
            > If you can post the code, so we can see how the $in
            > value is created, - we can help further.
            >
            > Gordon.
            >
            >
            >
            > ____________________________________________________________
            > Do You Yahoo!?
            > Get your free @... address at http://mail.yahoo.co.uk
            > or your free @... address at http://mail.yahoo.ie
          • Charles K. Clarkson
            ... [snip - thanks that was helpful.] ... I m confused: Do you want a link to the image?
            Message 5 of 8 , Jun 3, 2001
            • 0 Attachment
              <franky_claeys@...>

              : This is my enteire cgi-script:

              [snip - thanks that was helpful.]

              : [snip html code]
              :
              : #I need to make a dynamic link using the input from a
              : #html-form. The name of the html text field is tick
              : #the directory in wich the files are is clinegraphs
              : #I have find several solutions in cgi manuals but
              : #cannot make it work
              :

              I'm confused:

              Do you want a link to the image?

              <li>
              <a href="clinegraphs/$ticker{tick}.gif">
              <b>$ticker{tick}</b>
              </a>
              </li>

              Or do you want the image as a link?

              <li>
              <a href="path to some link">
              <img src="clinegraphs/$ticker{tick}.gif">
              </a>
              </li>


              : <img src="clinegraphs/\"$ticker{'tick'}.gif\"">
              :

              HTH,
              Charles K. Clarkson


              If you try to fail, and succeed, which have you done?
            • Greg
              ... work ... Try this: $href= clinegraphs/$ticker{ tick } ; print Lets Go n ; print
              Message 6 of 8 , Jun 4, 2001
              • 0 Attachment
                --- In perl-beginner@y..., franky_claeys@y... wrote:

                > [snip html code]
                >
                > #I need to make a dynamic link using the input from a html-form
                > #The name of the html text field is tick
                > #the directory in wich the files are is clinegraphs
                > #I have find several solutions in cgi manuals but cannot make it
                work
                >
                > <img src="clinegraphs/\"$ticker{'tick'}.gif\"">
                >
                >
                > [snip html code]

                Try this:

                $href="clinegraphs/$ticker{'tick'}";
                print "<html><head><title>Lets Go</title></head><body>\n";
                print "<a href=\"$href.html\"><img src=\"$href.gif\"></a>\n";
                print "</body></html>\n";

                Greg Smith
                webmaster
                www.bmw-club.org.uk
              Your message has been successfully submitted and would be delivered to recipients shortly.