Linking a

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bokke

    Linking a

    Hi - I am using this code

    echo "<tr><td></td><td id=tablesdirhea d>Property Information</td><td
    id=tablesdirhea d width='100'>Age nt Name</td><td id=tablesdirhea d
    width='150'>Con tact Info</td></tr>\n";
    while ($myrow = mysql_fetch_row ($result))
    {
    $row = 1-$row;
    $color = ($row==0)?"#F5F 5F5":"#F0F8FF" ;
    printf("<tr bgcolor=$color> <td>%s</td><td>%s</td><td>%s</td><td>%s</
    td></tr>\n",
    $myrow[5], $myrow[3], $myrow[0], $myrow[1]);
    }
    echo "</table>\n";
    ?>

    But would like to give the fourth "$myrow[1]" a PHP link like

    <a class="dir" href="processfo rmImage.php?act ion=&ID=<?php echo
    $row["StoreID"]; ?>">$myrow[1]</a>

    But can't seem to find anywhere on the web that shows this can even be
    done

  • flamer die.spam@hotmail.com

    #2
    Re: Linking a

    On May 18, 2:47 pm, bokke <micr...@gmail. comwrote:
    Hi - I am using this code
    >
    echo "<tr><td></td><td id=tablesdirhea d>Property Information</td><td
    id=tablesdirhea d width='100'>Age nt Name</td><td id=tablesdirhea d
    width='150'>Con tact Info</td></tr>\n";
    while ($myrow = mysql_fetch_row ($result))
    {
    $row = 1-$row;
    $color = ($row==0)?"#F5F 5F5":"#F0F8FF" ;
    printf("<tr bgcolor=$color> <td>%s</td><td>%s</td><td>%s</td><td>%s</
    td></tr>\n",
    $myrow[5], $myrow[3], $myrow[0], $myrow[1]);}
    >
    echo "</table>\n";
    ?>
    >
    But would like to give the fourth "$myrow[1]" a PHP link like
    >
    <a class="dir" href="processfo rmImage.php?act ion=&ID=<?php echo
    $row["StoreID"]; ?>">$myrow[1]</a>
    >
    But can't seem to find anywhere on the web that shows this can even be
    done
    echo " <a class=\"dir\" href=\"processf ormImage.php?ac tion=&ID=
    $row["StoreID"]\">$myrow[1]</a>";

    Flamer.

    Comment

    • Schraalhans Keukenmeester

      #3
      Re: Linking a

      At Thu, 17 May 2007 20:25:13 -0700, flamer die.spam@hotmai l.com let his
      monkeys type:
      On May 18, 2:47 pm, bokke <micr...@gmail. comwrote:
      >Hi - I am using this code
      >>
      >echo "<tr><td></td><td id=tablesdirhea d>Property Information</td><td
      >id=tablesdirhe ad width='100'>Age nt Name</td><td id=tablesdirhea d
      >width='150'>Co ntact Info</td></tr>\n";
      >while ($myrow = mysql_fetch_row ($result))
      > {
      > $row = 1-$row;
      > $color = ($row==0)?"#F5F 5F5":"#F0F8FF" ;
      > printf("<tr bgcolor=$color> <td>%s</td><td>%s</td><td>%s</td><td>%s</
      >td></tr>\n",
      > $myrow[5], $myrow[3], $myrow[0], $myrow[1]);}
      >>
      >echo "</table>\n";
      >?>
      >>
      >But would like to give the fourth "$myrow[1]" a PHP link like
      >>
      ><a class="dir" href="processfo rmImage.php?act ion=&ID=<?php echo
      >$row["StoreID"]; ?>">$myrow[1]</a>
      >>
      >But can't seem to find anywhere on the web that shows this can even be
      >done
      >
      echo " <a class=\"dir\" href=\"processf ormImage.php?ac tion=&ID=
      $row["StoreID"]\">$myrow[1]</a>";
      >
      Flamer.
      Both array references need to be enclosed in braces for this to work.
      Why not use heredoc syntax:

      echo <<<END
      <a class="dir"
      href= "processformIma ge.php?action=& ID=$row['StoreID']">$myrow[1]</a>
      END;

      Sh.

      Comment

      • Toby A Inkster

        #4
        Re: Linking a

        bokke wrote:
        $row = 1-$row;
        $color = ($row==0)?"#F5F 5F5":"#F0F8FF" ;
        This is bizarre. It took me a couple of minutes to figure out how it
        worked. A more usual method might be:

        $color = (++$row%2 == 1)?'#F5F5F5':'# F0F8FF';

        This would also allow you to count the rows in $row, which might be useful
        for some reason.

        --
        Toby A Inkster BSc (Hons) ARCS
        Fast withdrawal casino UK 2025 – Play now & cash out instantly! Discover the top sites for rapid, secure payouts with no delays.

        Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux

        Comment

        • Geoff Berrow

          #5
          Re: Linking a

          Message-ID: <1c10i4-8oj.ln1@ophelia .g5n.co.ukfrom Toby A Inkster
          contained the following:
          > $row = 1-$row;
          > $color = ($row==0)?"#F5F 5F5":"#F0F8FF" ;
          >
          >This is bizarre.
          I like it. :-)
          >$color = (++$row%2 == 1)?'#F5F5F5':'# F0F8FF';
          I like that too. I must be easily pleased.

          --
          Geoff Berrow (put thecat out to email)
          It's only Usenet, no one dies.
          My opinions, not the committee's, mine.
          Simple RFDs http://www.ckdog.co.uk/rfdmaker/

          Comment

          • Toby A Inkster

            #6
            Re: Linking a

            Geoff Berrow wrote:
            Toby A Inkster contained the following:
            >bokke wrote:
            >>
            >>$row = 1-$row;
            >>$color = ($row==0)?"#F5F 5F5":"#F0F8FF" ;
            >>
            >This is bizarre.
            >
            I like it. :-)
            I don't doubt its genius -- just its legibility.

            --
            Toby A Inkster BSc (Hons) ARCS
            Fast withdrawal casino UK 2025 – Play now & cash out instantly! Discover the top sites for rapid, secure payouts with no delays.

            Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux

            Comment

            • Alexey Kulentsov

              #7
              Re: Linking a

              Geoff Berrow wrote:
              Message-ID: <1c10i4-8oj.ln1@ophelia .g5n.co.ukfrom Toby A Inkster
              contained the following:
              >
              >> $row = 1-$row;
              >> $color = ($row==0)?"#F5F 5F5":"#F0F8FF" ;
              >This is bizarre.
              >
              I like it. :-)
              So you will like this, I hope:

              $color="#F5F5F5 ";
              $delta="#F0F8FF "^$c;

              while(...)
              {
              ....
              $color^=$delta;
              ....
              }

              Comment

              • satyakaran@gmail.com

                #8
                Re: Linking a

                On May 18, 7:47 am, bokke <micr...@gmail. comwrote:
                Hi - I am using this code
                >
                echo "<tr><td></td><td id=tablesdirhea d>Property Information</td><td
                id=tablesdirhea d width='100'>Age nt Name</td><td id=tablesdirhea d
                width='150'>Con tact Info</td></tr>\n";
                while ($myrow = mysql_fetch_row ($result))
                {
                $row = 1-$row;
                $color = ($row==0)?"#F5F 5F5":"#F0F8FF" ;
                printf("<tr bgcolor=$color> <td>%s</td><td>%s</td><td>%s</td><td>%s</
                td></tr>\n",
                $myrow[5], $myrow[3], $myrow[0], $myrow[1]);}
                >
                echo "</table>\n";
                ?>
                >
                But would like to give the fourth "$myrow[1]" a PHP link like
                >
                <a class="dir" href="processfo rmImage.php?act ion=&ID=<?php echo
                $row["StoreID"]; ?>">$myrow[1]</a>
                >
                But can't seem to find anywhere on the web that shows this can even be
                done
                And instead of writing printf();, you should write like this:

                echo '<tr>
                <td>'.$myrow[0].'</td>
                <td>'.$myrow[1].'</td>
                </tr>
                ';

                Here you can easily format/add anything for any column.
                echo '<tr>
                <td>'.$myrow[0].'</td>
                <td>'.$myrow[1].'</td>
                <td>'.$myrow[2].'</td>
                <td>'.$myrow[3].'</td>
                <td>'."<a class='dir' href='/index.php?store ID=$row[9]'>
                $myrow[4]</a>.'</td>
                </tr>
                ';


                satya61229.blog spot.com

                Comment

                • Schraalhans Keukenmeester

                  #9
                  Re: Linking a

                  At Sun, 20 May 2007 23:35:06 -0700, satyakaran let his monkeys type:
                  On May 18, 7:47 am, bokke <micr...@gmail. comwrote:
                  >Hi - I am using this code
                  >>
                  >echo "<tr><td></td><td id=tablesdirhea d>Property Information</td><td
                  >id=tablesdirhe ad width='100'>Age nt Name</td><td id=tablesdirhea d
                  >width='150'>Co ntact Info</td></tr>\n"; while ($myrow =
                  >mysql_fetch_ro w($result))
                  > {
                  > $row = 1-$row;
                  > $color = ($row==0)?"#F5F 5F5":"#F0F8FF" ;
                  > printf("<tr
                  > bgcolor=$color> <td>%s</td><td>%s</td><td>%s</td><td>%s</
                  >td></tr>\n",
                  > $myrow[5], $myrow[3], $myrow[0], $myrow[1]);}
                  >>
                  >echo "</table>\n";
                  >?>
                  >>
                  >But would like to give the fourth "$myrow[1]" a PHP link like
                  >>
                  ><a class="dir" href="processfo rmImage.php?act ion=&ID=<?php echo
                  >$row["StoreID"]; ?>">$myrow[1]</a>
                  >>
                  >But can't seem to find anywhere on the web that shows this can even be
                  >done
                  >
                  And instead of writing printf();, you should write like this:
                  >
                  echo '<tr>
                  <td>'.$myrow[0].'</td>
                  <td>'.$myrow[1].'</td>
                  </tr>
                  ';
                  >
                  Here you can easily format/add anything for any column. echo '<tr>
                  <td>'.$myrow[0].'</td>
                  <td>'.$myrow[1].'</td>
                  <td>'.$myrow[2].'</td>
                  <td>'.$myrow[3].'</td>
                  <td>'."<a class='dir' href='/index.php?store ID=$row[9]'>
                  $myrow[4]</a>.'</td>
                  </tr>
                  ';
                  >
                  >
                  satya61229.blog spot.com
                  Which I personally find a surefire way of introducing many typos.
                  Using double quotes instead of concatenation and braces around the
                  $myrow[n] 's is a little less error-prone if you ask me, then sprintf() is
                  a candidate you may want to consider and better still imho is using
                  heredoc syntax in these cases. Stepping out of php and surrounding all the
                  array references with <?PHP ;?is over the top here.

                  echo <<<HTML_END
                  <tr>
                  <td>$myrow[0]</td>
                  <td>$myrow[1]</td>
                  <td>$myrow[2]</td>
                  <td>$myrow[3]</td>
                  <td><a class='dir'
                  href='/index.php?store ID=$row[9]'>$myrow[4]</a></td>
                  </tr>
                  HTML_END;

                  Sh.

                  Comment

                  Working...