carrying over string value to other pages

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fructose
    New Member
    • Sep 2006
    • 8

    carrying over string value to other pages

    Thanks for help on my first post about the glossary entries guys. I've run into a bigger problem on the same topic though. (Forget anything I said in the last post, this is a separate point).

    OK, here's the deal: I've got a page with hundreds of technical terms on it, and I want each term to link to a glossary

    entry on a separate page.

    That would be simple, except I want the printed data of each glossary entry to be a small file which will be accessed by a

    'php include' from a template page called 'glossarytempla te.php'. 'glossarytempla te.php' has loads of other includes for

    menus, java scripts, changeable graphics, roll-over messages etc, so to make a perfectly formatted page for each glossary

    entry with all the necessary includes would be dangerous, as changing my mind about any presentation or structure would

    result in a nightmarish update process.

    Here's an example of my code from the page containing the article with all the technical terms:


    <a <?php $entry == $augmented; ?> href="glossaryt emplate.php">au gmented</a>


    My theory was that clicking on the word 'augmented' would assign equate $augmented with the string $entry, and that I

    would use $entry on the glossarytemplat e.php page, thus:


    <?php

    $no_data = "<p>This definition is coming soon. Please check back later.</p>";

    if ($entry == $augmented) {include ("glossaryda ta/augmented.html" );}
    elseif ($entry == $tritone) {include ("glossaryda ta/tritone.html"); }
    elseif ($entry == $kurchatov) {include ("glossaryda ta/kurchatov.html" );}
    else
    {echo $no_data;}

    ?>


    It seems, however, that the value of $entry won't be carried over to another page. Any solutions?

    A bigger problem (and one which may render all the above void), is that my 'elseif''s will run into the hundreds using this method. Is there a command for rendering something equivalent to the following plain-English?


    {include ("glossaryda ta/the name of the file that's in the $entry string.html");}


    Thanks a lot,

    fructose
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Your <a > tag assignment is wrong, you use the logical compare operator (==)instead of the assignment operator )=). That statement should be
    [PHP]<a <?php $entry = $augmented; ?> href="glossaryt emplate.php">au gmented</a>
    [/PHP]
    However, the variable $entry is always set, whether you click or not.
    If you want it to be set when clicked, you'd better use JavaScript with an onClick() function.

    Ronald :cool:

    Comment

    • fructose
      New Member
      • Sep 2006
      • 8

      #3
      Thanks Ronals,

      All points duly noted. :-)

      I need to avoid javascript for sensing the click for accessibility reasons though.

      Can you point me in the right direction regarding any other approach? Perhaps I could direct each click to its own page, rather than to the glossarytemplat e, but then each of these pages would be a mere include to the template, then, using PHP, I could ask what the filename was of the page that directed to the glossarytemplat e. The filename data would allow me to call the appropriate file with the definition.

      Would that work?

      Cheers,

      fructose

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        How about setting the $augmented value dynamically in the link href with parm value? like this
        [PHP]
        <?php
        echo "<a href='glossaryt emplate.php?val ue=$augmented'> augmented</a>";
        ?>[/PHP]
        In your receiving script you would have to interrogate the $_GET array, as follows (without parameter cleansing, you'll do that yourself):
        [PHP]
        <?php
        $if (isset($_GET['value'])
        $augmented = $_GET['value'];
        else
        // whatever you want to do when value is not set
        ?>
        [/PHP]

        Ronald :cool:

        Comment

        Working...