Search code examples
phphtmlhreflocation-href

HTML/PHP href Multiple Parameters


I've got this line of code:

echo "<tr><td colspan='2'><a href='$row['type']/$row['id']/$row['wfurl']'>".($row['title'])."</a></td></tr>";

What i'm trying to achieve is a href that directs to /news/546/my-url-says-this, the link is firing from the sites home directory. How do I put multiple PHP parameters in a href link? And how do i solve the '' "" issues i seem to be experiencing?


Solution

  • Just to debug, try binding actual variables to the stuff you're pulling (I imagine you're pulling from a SQL DB with while($row = ...), right?).

    So you'd have:

    $type = $row['type'];
    $id   = $row['id'];
    ...
    

    Then try the echo with escaped double quotation marks and slashes and concatenation (what you're missing):

    echo "<tr><td colspan=\"2\"><a href=\"".$type."/".$id."/".$wfurl."\">".$title."</a></td></tr>";