how to generate hyperlink for entire column of number ID in a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sheau Wei
    New Member
    • Sep 2006
    • 34

    how to generate hyperlink for entire column of number ID in a table

    when the result print out , i want to make hyperlink for entire column of ID. what should i do?Below was my php code.

    //And we display the results
    while($result = mysql_fetch_arr ay( $data ))
    {


    echo "<tr><td>";
    echo $result['ID'];
    echo "</td><td>";
    echo $result['NamaPeralatan'];
    echo "</td><td>";
    echo $result['Motor'];
    echo "</td><td>";
    echo $result['Operasi'];
    echo "</td><td>";
    }
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Don't understand your question fully. Do you want a link in the id column to where? If so, the following will do that.
    [PHP]echo "<tr><td><a href='AnotherPa ge.php?id={$res ult['ID']}'>{$result['ID']}</a></td>
    <td>{$result['NamaPeralatan']}</td>
    <td>{$result['Motor']}</td>
    <td>{$result['Operasi']}</td>
    </tr>"; [/PHP]

    Ronald :cool:

    Comment

    • Sheau Wei
      New Member
      • Sep 2006
      • 34

      #3
      Originally posted by ronverdonk
      Don't understand your question fully. Do you want a link in the id column to where? If so, the following will do that.
      [PHP]echo "<tr><td><a href='AnotherPa ge.php?id={$res ult['ID']}'>{$result['ID']}</a></td>
      <td>{$result['NamaPeralatan']}</td>
      <td>{$result['Motor']}</td>
      <td>{$result['Operasi']}</td>
      </tr>"; [/PHP]

      Ronald :cool:
      yes , i was sucess to create it .thanks a lot

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        The AnotherPage.php looks like this:

        [php]
        <?php
        // check if id is passed to this routine
        if (isset($_GET['id']) {
        // if yes: remove harmful tags and save the passed id in variable $id
        $id = strip_tags($_GE T['id']);
        // now you can do your MySql functions (sample)
        // connect to server .....
        // connect to data base .....

        // construct SQL statement
        $sql = "SELECT field1, field2, ... from table_name WHERE ID='$id'";
        // execute the select
        }
        else { // id not passed to this function
        echo "Id was not passed to this routine";
        die;
        }
        [/php]

        Ronald :cool:

        Comment

        Working...