Reputation: 395
I want display my button if it have isset($_GET). I am trying to do like this.
<?php if(isset($_GET['project_id'])){
echo '<div class="add_btn_primary"> <a href="manage_project_users.php?project_id=<?php echo $_GET['project_id'];?>">Project Users</a> </div>';
}?>
its giving me error like
Parse error: syntax error, unexpected 'project_id' (T_STRING), expecting ',' or ';' in C:\xamppp\htdocs\mayank\add_project.php on line 101
I am not getting idea what I should do for echo project_id in div. Let me know if someone can help me for that. Thanks
Upvotes: 0
Views: 579
Reputation: 189
Thats incorrect to use echo inside another echo and how can you start a new php tag without closing the first. The correct way is to concatenate the variable along the string passed in echo, here is how
<?php if(isset($_GET['project_id'])){
echo '<div class="add_btn_primary"> <a href="manage_project_users.php?project_id='.$_GET['project_id'].'">Project Users</a> </div>';
}?>
instead of breaking the php tags break the ' quotes to concatenate the value in the string.
Upvotes: 1
Reputation: 846
Why do you need again tag inside echo just use it as below:
<?php
if(isset($_GET['project_id']))
{
echo ('<div class="add_btn_primary"><a href="manage_project_users.php?project_id='.$_GET["project_id"].'>Project Users</a></div>');
}
?>
Upvotes: 1