Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Variable in href in table

    I would like each field in a table (generated from an Oracle database) to be a link to a different page. For example, all rows in field one would link to "linkone.php", all rows from field 2 would link to "linktwo.php, and all rows from field three would link to "linkthree.php".

    I think the best way to do this is to use a $VARIABLE, based on $i as in the code below. But I can't figure out the syntax for placing a variable in my href.

    // Read fetched data.
    while (oci_fetch($s))
    {
    // Print open and close HTML row tags and columns data.
    print '<tr>';
    for ($i = 1;$i <= oci_num_fields($s);$i++)
    print '<td class="v"><a href=\'$VARIABLE.php?dataset='.oci_result($s,$i).'\'>'.oci_result($s,$i).'</td>';
    print '</tr>';
    }
    Any help would be greatly appreciated.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Because you are using single quotes on your print statement you need to concatenate your variable which you seem to have done for your other variables. Try this
    PHP Code:
    // Read fetched data.
    while (oci_fetch($s))
    {
    // Print open and close HTML row tags and columns data.
    print '<tr>';
    for (
    $i 1;$i <= oci_num_fields($s);$i++)
    print 
    '<td class="v"><a href="'.$VARIABLE.'.php?dataset='.oci_result($s,$i).'">'.oci_result($s,$i).'</td>';
    print 
    '</tr>';

    Last edited by _Aerospace_Eng_; 07-10-2007 at 06:24 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks much!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •