当我回显我的字符串时,它显示为ex:1,1但是我想让它像这个关键字名称:结果,我得到的结果
这是我的代码:
<?php
if(isset($_POST['button2']))
{
$portal = mysqli_real_escape_string($link, $_POST['field1']);
$keywords = $_POST['field2'];
$keyword_tokens = explode(',', $keywords);
$string = "";
foreach($keyword_tokens as $keyword)
{
$keyword = (trim($keyword));
$sql = mysqli_query($link, "SELECT * FROM conteudo WHERE d_portal='$portal' and d_keyword REGEXP '$keyword'");
$result = mysqli_num_rows($sql);
$rows = array();
$string .= $keyword." : ".$result.', ';
}
}
echo $string;
?>
有人能帮助我吗?谢谢你,祝你有个愉快的一天。
答案 0 :(得分:0)
<?php
if(isset($_POST['button2']))
{
$portal = mysqli_real_escape_string($link, $_POST['field1']);
$keywords = $_POST['field2'];
$keyword_tokens = explode(',', $keywords);
$string = "";
foreach($keyword_tokens as $keyword)
{
$keyword = (trim($keyword));
$sql = mysqli_query($link, "SELECT * FROM conteudo WHERE d_portal='$portal' and d_keyword REGEXP '$keyword'");
$result = mysqli_num_rows($sql);
$rows = array();
$string .= $keyword." : ".$result.', ';
}
}
echo $string;
?>
这可能会给你输出如下 -
Keyword1:5,Keyword2:3,Keyword3:15,Keyword4:23,......