Opening links from a table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • phill.luckhurst@googlemail.com

    Opening links from a table

    I'm using the following code to display som items from a database.

    field_2 shows a link that is clickable. I would like to make it
    clickable but open the link in a new page (in a _blank way) instead of
    onto itself but I'm not sure how to do it.

    {
    echo "var point = new GLatLng(" . $row['field_5'] . "," .
    $row['field_4'] . ");\n";
    echo "var marker = createMarker(po int, '" .
    addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
    \">". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
    echo "map.addOverlay (marker);\n";
    echo "\n";
    }

  • Lammi

    #2
    Re: Opening links from a table

    why not:
    {
    echo "var point = new GLatLng(" . $row['field_5'] . "," .
    $row['field_4'] . ");\n";
    echo "var marker = createMarker(po int, '" .
    addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
    \" target='_blank' >". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
    echo "map.addOverlay (marker);\n";
    echo "\n";
    >
    }

    Comment

    • Lars Eighner

      #3
      Re: Opening links from a table

      In our last episode,
      <1182150012.452 777.122840@u2g2 000hsc.googlegr oups.com>,
      the lovely and talented phill.luckhurst @googlemail.com
      broadcast on comp.lang.php:
      I'm using the following code to display som items from a database.
      field_2 shows a link that is clickable. I would like to make it
      clickable but open the link in a new page (in a _blank way) instead of
      onto itself but I'm not sure how to do it.
      How exactly is this a PHP problem and not a Javascript problem?

      --
      Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
      Countdown: 582 days to go.
      An amazing thing about Christians: people who doubt being related to monkeys,
      but are certain they belong to the same species as Paris Hilton or Karl Rove.

      Comment

      • phill.luckhurst@googlemail.com

        #4
        Re: Opening links from a table

        On 18 Jun, 08:30, Lammi <Lorenz.Lammers d...@gmail.comw rote:
        why not:
        >
        >
        >
        {
        echo "var point = new GLatLng(" . $row['field_5'] . "," .
        $row['field_4'] . ");\n";
        echo "var marker = createMarker(po int, '" .
        addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
        \" target='_blank' >". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
        echo "map.addOverlay (marker);\n";
        echo "\n";
        >
        }- Hide quoted text -
        >
        - Show quoted text -
        Beacuse I'm useless

        Comment

        • phill.luckhurst@googlemail.com

          #5
          Re: Opening links from a table

          On 18 Jun, 08:30, Lammi <Lorenz.Lammers d...@gmail.comw rote:
          why not:
          >
          >
          >
          {
          echo "var point = new GLatLng(" . $row['field_5'] . "," .
          $row['field_4'] . ");\n";
          echo "var marker = createMarker(po int, '" .
          addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
          \" target='_blank' >". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
          echo "map.addOverlay (marker);\n";
          echo "\n";
          >
          }- Hide quoted text -
          >
          - Show quoted text -
          Because I'n useless and still cannot work it out. I'm now going to
          hide in a corner and cry.

          Comment

          • Toby A Inkster

            #6
            Re: Opening links from a table

            phill.luckhurst @googlemail.com wrote:
            echo "var point = new GLatLng(" . $row['field_5'] . "," .
            $row['field_4'] . ");\n";
            echo "var marker = createMarker(po int, '" .
            addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
            \">". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
            echo "map.addOverlay (marker);\n";
            echo "\n";
            This kind of mess can be avoided by liberal use of printf.

            printf("var point = new GLatLng(%f, %f);\n"
            ."var marker = createMarker(po int, '%s<br /><a href=\"%s\">%s</a><br />%s', 3);\n"
            ."map.addOverla y(marker);\n\n"
            , $row['field_5']
            , $row['field_4']
            , addslashes(html entities($row['field_1']))
            , addslashes(html entities($row['field_2']))
            , addslashes(html entities($row['field_2']))
            , addslashes(html entities($row['field_3']))
            );

            Or better still:

            $markertext = sprintf('%s<br /><a href="%s">%s</a><br />%s'
            , htmlentities($r ow['field_1'])
            , htmlentities($r ow['field_2'])
            , htmlentities($r ow['field_2'])
            , htmlentities($r ow['field_3'])
            );
            printf("var point = new GLatLng(%f, %f);\n"
            ."var marker = createMarker(po int, '%s', 3);\n"
            ."map.addOverla y(marker);\n\n"
            , $row['field_5']
            , $row['field_4']
            , addslashes($mar kertext)
            );

            This makes it clear where to add your target="_blank" :

            $markertext = sprintf('%s<br /><a href="%s" target="_blank" >%s</a><br />%s'
            , htmlentities($r ow['field_1'])
            , htmlentities($r ow['field_2'])
            , htmlentities($r ow['field_2'])
            , htmlentities($r ow['field_3'])
            );
            printf("var point = new GLatLng(%f, %f);\n"
            ."var marker = createMarker(po int, '%s', 3);\n"
            ."map.addOverla y(marker);\n\n"
            , $row['field_5']
            , $row['field_4']
            , addslashes($mar kertext)
            );

            Though I'd avoid creating a popup like this -- it breaks the "back"
            button and confuses users.

            --
            Toby A Inkster BSc (Hons) ARCS
            [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
            [OS: Linux 2.6.12-12mdksmp, up 114 days, 18:42.]

            You're Not Allowed to Take Pictures of the US Embassy in Rome

            Comment

            • phill.luckhurst@googlemail.com

              #7
              Re: Opening links from a table

              On 18 Jun, 12:08, Toby A Inkster <usenet200...@t obyinkster.co.u k>
              wrote:
              phill.luckhu... @googlemail.com wrote:
              echo "var point = new GLatLng(" . $row['field_5'] . "," .
              $row['field_4'] . ");\n";
              echo "var marker = createMarker(po int, '" .
              addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
              \">". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
              echo "map.addOverlay (marker);\n";
              echo "\n";
              >
              This kind of mess can be avoided by liberal use of printf.
              >
              printf("var point = new GLatLng(%f, %f);\n"
              ."var marker = createMarker(po int, '%s<br /><a href=\"%s\">%s</a><br />%s', 3);\n"
              ."map.addOverla y(marker);\n\n"
              , $row['field_5']
              , $row['field_4']
              , addslashes(html entities($row['field_1']))
              , addslashes(html entities($row['field_2']))
              , addslashes(html entities($row['field_2']))
              , addslashes(html entities($row['field_3']))
              );
              >
              Or better still:
              >
              $markertext = sprintf('%s<br /><a href="%s">%s</a><br />%s'
              , htmlentities($r ow['field_1'])
              , htmlentities($r ow['field_2'])
              , htmlentities($r ow['field_2'])
              , htmlentities($r ow['field_3'])
              );
              printf("var point = new GLatLng(%f, %f);\n"
              ."var marker = createMarker(po int, '%s', 3);\n"
              ."map.addOverla y(marker);\n\n"
              , $row['field_5']
              , $row['field_4']
              , addslashes($mar kertext)
              );
              >
              This makes it clear where to add your target="_blank" :
              >
              $markertext = sprintf('%s<br /><a href="%s" target="_blank" >%s</a><br />%s'
              , htmlentities($r ow['field_1'])
              , htmlentities($r ow['field_2'])
              , htmlentities($r ow['field_2'])
              , htmlentities($r ow['field_3'])
              );
              printf("var point = new GLatLng(%f, %f);\n"
              ."var marker = createMarker(po int, '%s', 3);\n"
              ."map.addOverla y(marker);\n\n"
              , $row['field_5']
              , $row['field_4']
              , addslashes($mar kertext)
              );
              >
              Though I'd avoid creating a popup like this -- it breaks the "back"
              button and confuses users.
              >
              --
              Toby A Inkster BSc (Hons) ARCS
              [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
              [OS: Linux 2.6.12-12mdksmp, up 114 days, 18:42.]
              >
              You're Not Allowed to Take Pictures of the US Embassy in Rome
              http://tobyinkster.co.uk/blog/2007/06/16/us-embassy/
              Thank you Toby.

              This is my first fray into coding so am greatful for your help. It's
              quite a learning curve.

              Comment

              Working...