PHP MYSQLi:PHP变量内的条件
我有一系列sql语句和while循环,它们显示存储在变量$topics中的主题信息,该变量中有一个删除主题的链接 我想做的是使该链接仅对管理员可见,条件如下: if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") 如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”) 我该怎么做?链接必须留在变量内部,因为每个主题旁边都有自己的删除链接 这是变量$topics,它位于while循环中PHP MYSQLi:PHP变量内的条件,php,Php,我有一系列sql语句和while循环,它们显示存储在变量$topics中的主题信息,该变量中有一个删除主题的链接 我想做的是使该链接仅对管理员可见,条件如下: if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") 如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”) 我该怎么做?链接必须留在变量内部,因为每个主题旁边都有自己的删除链
$topics.=”代码>在我看来,它只是:
$topics .= "<tr><td><a href='view_topic.php?cid=".$cid."&tid=".$tid."'>".$title."</a><br /><span class ='post_info'>Posted by: ".getUsername($creator)." on ".convertDate($date)."</span></td><td align='center'>".topicReplies($cid, $tid)."</td><td align='center'>".$views."</td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator"){
$topics .= "<td><a id='del' href='deletetopic.php?del=$tid'>Delete</a></td>";
}else{
$topics .= "<td> </td>";
}
$topics .= "</tr>";
$topics.=“
发布人:“.getUsername($creator)。”on.convertDate($date)。”.topicReplies($cid,$tid)。“.$views.”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}否则{
$topics.=”;
}
$topics.=”;
这将附加始终附加的信息,有条件地附加删除链接,然后以
结束该行。在我看来,它只是:
$topics .= "<tr><td><a href='view_topic.php?cid=".$cid."&tid=".$tid."'>".$title."</a><br /><span class ='post_info'>Posted by: ".getUsername($creator)." on ".convertDate($date)."</span></td><td align='center'>".topicReplies($cid, $tid)."</td><td align='center'>".$views."</td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator"){
$topics .= "<td><a id='del' href='deletetopic.php?del=$tid'>Delete</a></td>";
}else{
$topics .= "<td> </td>";
}
$topics .= "</tr>";
$topics.=“
发布人:“.getUsername($creator)。”on.convertDate($date)。”.topicReplies($cid,$tid)。“.$views.”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}否则{
$topics.=”;
}
$topics.=”;
这将附加始终附加的信息,有条件地附加删除链接,然后以
结束该行。在我看来,它只是:
$topics .= "<tr><td><a href='view_topic.php?cid=".$cid."&tid=".$tid."'>".$title."</a><br /><span class ='post_info'>Posted by: ".getUsername($creator)." on ".convertDate($date)."</span></td><td align='center'>".topicReplies($cid, $tid)."</td><td align='center'>".$views."</td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator"){
$topics .= "<td><a id='del' href='deletetopic.php?del=$tid'>Delete</a></td>";
}else{
$topics .= "<td> </td>";
}
$topics .= "</tr>";
$topics.=“
发布人:“.getUsername($creator)。”on.convertDate($date)。”.topicReplies($cid,$tid)。“.$views.”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}否则{
$topics.=”;
}
$topics.=”;
这将附加始终附加的信息,有条件地附加删除链接,然后以
结束该行。在我看来,它只是:
$topics .= "<tr><td><a href='view_topic.php?cid=".$cid."&tid=".$tid."'>".$title."</a><br /><span class ='post_info'>Posted by: ".getUsername($creator)." on ".convertDate($date)."</span></td><td align='center'>".topicReplies($cid, $tid)."</td><td align='center'>".$views."</td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator"){
$topics .= "<td><a id='del' href='deletetopic.php?del=$tid'>Delete</a></td>";
}else{
$topics .= "<td> </td>";
}
$topics .= "</tr>";
$topics.=“
发布人:“.getUsername($creator)。”on.convertDate($date)。”.topicReplies($cid,$tid)。“.$views.”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}否则{
$topics.=”;
}
$topics.=”;
这将附加始终附加的信息,有条件地附加删除链接,然后使用
完成该行。您应该能够执行以下操作:
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<tr><td><a id='del' href='deletetopic.php?del=$tid'>Delete</a></td></tr>";
}
if(isset($\u SESSION['level'])和&(string)$\u SESSION['level']=“管理员”){
$topics.=”;
}
甚至可以将内容再拆分一点,这样您就可以得到一个空的表格单元格,而不是一无所有:
$topics .= "<tr><td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<a id='del' href='deletetopic.php?del=$tid'>Delete</a>";
}
$topics .= "</td></tr>";
$topics.=”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}
$topics.=”;
编辑:
这应该起作用:
$topics .= "<tr><td><a href='view_topic.php?cid=".$cid."&tid=".$tid."'>".$title."</a><br /><span class ='post_info'>Posted by: ".getUsername($creator)." on ".convertDate($date)."</span></td><td align='center'>".topicReplies($cid, $tid)."</td><td align='center'>".$views."</td><td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<a id='del' href='deletetopic.php?del=$tid'>Delete</a>";
}
$topics .= "</td></tr>";
$topics.=“
发布人:“.getUsername($creator)。”on.convertDate($date)。”.topicReplies($cid,$tid)。“.$views.”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}
$topics.=”;
您应该能够执行以下操作:
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<tr><td><a id='del' href='deletetopic.php?del=$tid'>Delete</a></td></tr>";
}
if(isset($\u SESSION['level'])和&(string)$\u SESSION['level']=“管理员”){
$topics.=”;
}
甚至可以将内容再拆分一点,这样您就可以得到一个空的表格单元格,而不是一无所有:
$topics .= "<tr><td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<a id='del' href='deletetopic.php?del=$tid'>Delete</a>";
}
$topics .= "</td></tr>";
$topics.=”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}
$topics.=”;
编辑:
这应该起作用:
$topics .= "<tr><td><a href='view_topic.php?cid=".$cid."&tid=".$tid."'>".$title."</a><br /><span class ='post_info'>Posted by: ".getUsername($creator)." on ".convertDate($date)."</span></td><td align='center'>".topicReplies($cid, $tid)."</td><td align='center'>".$views."</td><td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<a id='del' href='deletetopic.php?del=$tid'>Delete</a>";
}
$topics .= "</td></tr>";
$topics.=“
发布人:“.getUsername($creator)。”on.convertDate($date)。”.topicReplies($cid,$tid)。“.$views.”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}
$topics.=”;
您应该能够执行以下操作:
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<tr><td><a id='del' href='deletetopic.php?del=$tid'>Delete</a></td></tr>";
}
if(isset($\u SESSION['level'])和&(string)$\u SESSION['level']=“管理员”){
$topics.=”;
}
甚至可以将内容再拆分一点,这样您就可以得到一个空的表格单元格,而不是一无所有:
$topics .= "<tr><td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<a id='del' href='deletetopic.php?del=$tid'>Delete</a>";
}
$topics .= "</td></tr>";
$topics.=”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}
$topics.=”;
编辑:
这应该起作用:
$topics .= "<tr><td><a href='view_topic.php?cid=".$cid."&tid=".$tid."'>".$title."</a><br /><span class ='post_info'>Posted by: ".getUsername($creator)." on ".convertDate($date)."</span></td><td align='center'>".topicReplies($cid, $tid)."</td><td align='center'>".$views."</td><td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<a id='del' href='deletetopic.php?del=$tid'>Delete</a>";
}
$topics .= "</td></tr>";
$topics.=“
发布人:“.getUsername($creator)。”on.convertDate($date)。”.topicReplies($cid,$tid)。“.$views.”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}
$topics.=”;
您应该能够执行以下操作:
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<tr><td><a id='del' href='deletetopic.php?del=$tid'>Delete</a></td></tr>";
}
if(isset($\u SESSION['level'])和&(string)$\u SESSION['level']=“管理员”){
$topics.=”;
}
甚至可以将内容再拆分一点,这样您就可以得到一个空的表格单元格,而不是一无所有:
$topics .= "<tr><td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<a id='del' href='deletetopic.php?del=$tid'>Delete</a>";
}
$topics .= "</td></tr>";
$topics.=”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}
$topics.=”;
编辑:
这应该起作用:
$topics .= "<tr><td><a href='view_topic.php?cid=".$cid."&tid=".$tid."'>".$title."</a><br /><span class ='post_info'>Posted by: ".getUsername($creator)." on ".convertDate($date)."</span></td><td align='center'>".topicReplies($cid, $tid)."</td><td align='center'>".$views."</td><td>";
if (isset($_SESSION['level']) && (string) $_SESSION['level'] === "Administrator") {
$topics .= "<a id='del' href='deletetopic.php?del=$tid'>Delete</a>";
}
$topics .= "</td></tr>";
$topics.=“
发布人:“.getUsername($creator)。”on.convertDate($date)。”.topicReplies($cid,$tid)。“.$views.”;
如果(isset($_会话['level'])和(&(string)$_会话['level']=“管理员”){
$topics.=”;
}
$topics.=”;
在条件后加上花括号,然后在其中加上$topics
的echo
,有什么不对?在条件后加上花括号,然后在其中加上$topics
的echo
有什么不对?在条件后加上花括号,有什么不对,然后把echo
的$topics
放在里面?在条件后面放大括号有什么错,然后把echo
的$topics
放在里面?是的,但是变量包含许多我不想对t隐藏的其他数据