Need a Small Fix - Calling Variable as URL and Title

Discussion in 'PHP' started by Trikkur, May 12, 2011.

  1. #1
    Hi, I'm totally new to programming, but I broke a theme I've been using and trying to fix it. I've got some very basic understanding, but need just a bit of help to fix this problem.

    I messed up the code for my sidebar and I'm not sure what it originally looked like. I believe it was something like this

    <?php
    function tilt_sidebar_link($title, $loc) {
    echo "<li><a href="$loc">$title</a></li>";
    }
    ?>

    This doesn't work though. I can output just a $title, or even just a $loc, but whenever I try to use the variables in the <a href= code it doesn't work. Does anyone know how I can call these 2 variable to create a list of links for my sidebar?


    Here is the rest of the code that is still in tact. I've edited parts of it out, but everything relevant is still here.

    <div id="left-bar" class="sidebar">
    <div id="left-bar-inside">
    <br />
    <p align="center">Stuff</p>
    <p>Stuff</p>
    <p>More Stuff</p>
    <h2>Header Stuff</h2>

    <ul>
    <?php
    tilt_sidebar_link('Real Keywords, 'http://www.Real Keywords.com');
    tilt_sidebar_link('Real 123ABC', 'http://www.Rea123ABC.com');
    </ul>
    <br />
    <h2>Links</h2>
    <ul>
    <?php
    tilt_sidebar_link('Keywords', 'URL.com');
    tilt_sidebar_link('Keywords', 'URL.com');
    ?>
    </ul>
    <br />
    </div>
    </div>
     
    Last edited: May 12, 2011
    Trikkur, May 12, 2011 IP
  2. Jane Management

    Jane Management Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    function tilt_sidebar_link($title, $loc)
    {
         echo "<li><a href=\"$loc\">$title</a></li>";
    }
    PHP:
    Try it and let us know the outcome :)
     
    Jane Management, May 12, 2011 IP
  3. Trikkur

    Trikkur Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Perfect. Thanks so much. Proper syntax has always been my downfall.
     
    Trikkur, May 12, 2011 IP