0v3k Shi3ld3r 0v3k Shi3ld3r - 5 months ago 11
PHP Question

Correctly Formatting URL with variable(s)

I have the following line below as a URL

//someplace/forum/view_topic.php?cid=1&tid=2

I would like replace cid & tid for the below values

$topic_tid= $row->cat_id;

$topic_id= $row->id;


I have tried the following (Not Working)

echo "<a href=view_topic.php?cid=".$topic_id."&tid"=.$topic_tid.">Result</a>";


How can I correctly format the above line please

Answer

You should use proper quotes (single) for href assign and proper content in "&tid=" (missing = .. your is outside the string)

echo "<a href='view_topic.php?cid=".$topic_id."&tid=".$topic_tid."'>Result</a>";