首页 > 解决方案 > How to show a link if user_id =1 in HTML with PHP

问题描述

I am new and learning PHP and HTML. I have one user table where I am displaying data. I want to show Delete button if user_id = 1. else I want to hide it. My current link code is like below

<a href="<?php echo site_url('members/delete/'.$row['user_id']); ?>" class="btn btn-danger" onclick="return confirm('Are you sure to delete?')">delete</a>

I have done PHP code for doing achieve my above description

<?php
if ($row['user_id']==1){
echo //// I want a link here
}
?>

But since my link have also used some PHP codes, I am confused and not able to properly echo button. I am trying from an hour and not able to fix it. Let me know if someone can help me for do it.

Thanks!

标签: phphtmlcodeigniter

解决方案


you can put html code in echo like this

 echo "<tag name></tag name>"

推荐阅读