ToTensor 2021-05-31 15:48 采纳率: 50%
浏览 19
已结题

怎么从英文文本中提取出代码呢?求大佬解答

"<div class=""post-text"" itemprop=""text"">

<p>I have a function where I get all information in my users. At the end of the string, I give the admin the option to delete the user, based on the users id.</p>

<p>My string:</p>

<pre><code>while ( $row = $result-&gt;fetch_assoc () ) {
   $string .= ""&lt;tr&gt;&lt;td&gt;"" . $row ['id'] . ""&lt;/td&gt;&lt;td&gt;"" . $row ['first_name'] . ""&lt;/td&gt;&lt;td&gt;"" . $row ['last_name'] . ""&lt;/td&gt;&lt;td&gt;"" . $row ['email'] . ""&lt;/td&gt;&lt;td&gt;"" . $row ['role_name'] . ""&lt;/td&gt;&lt;td&gt;[&lt;a href='delete.php?id="" . $row ['id'] . ""'&gt;Delete&lt;/a&gt;]&lt;/td&gt;&lt;/tr&gt;"";
}
</code></pre>

<p>My delete page:</p>

<pre><code>if ($user-&gt;deleteUser($_GET['id']))
{
    header(""Location: admin.php"");
}
else
{
    echo ""Could not delete the user!"";
}
</code></pre>

<p>And my delete user function:</p>

<pre><code>public function deleteUser($id)
{
    $sql = ""DELETE FROM users WHERE id = ?"";
    if (!$result = $this-&gt;db-&gt;mysqli-&gt;prepare($sql))
    {
        return false;
    }

    if (!$result-&gt;bind_param('i', $id))
    {
        return false;
    }

    return $result-&gt;execute();
}
</code></pre>

<p>And all of this works fine. </p>

<p>What I wan't to know, is how can I promt admin with an alert, saying: ""Are you sure?"" for example. </p>
    </div>"

如想从上面代码段抽取出代码,有没有大佬救救孩子

  • 写回答

1条回答 默认 最新

  • ToTensor 2021-06-02 11:22
    关注

    大佬救救我

    评论

报告相同问题?