gpt4 book ai didi

php - 选择带有单词 mysql 的 url 的 preg_match_all id

转载 作者:行者123 更新时间:2023-11-29 20:33:35 25 4
gpt4 key购买 nike

想要使用 select 命令从 sql 中获取新闻 id我用 php 运行它

   //get the last part
$arrayUrl=explode("/",$url);
$finalPath=$arrayUrl[count($arrayUrl)-1];

preg_match("/\d+/",$finalPath,$matches);

URL 格式示例:

http://www.xxxx.com/t1134133-0 
http://www.xxxx.com/t1134133-2
http://www.xxxx.com/t1134133-3
http://www.xxxx.com/t1134133-news-news-worlds
http://www.xxxx.com/t1134133-mi%20&ffjfj

但我需要尝试获取像 1134133 这样的 id 组并对其进行计数我尝试一下

    <?                  $seleddcddddddtMaidfsdfgnwork =
"SELECT * FROM `online_site` WHERE `url` LIKE '%http://www. xxxx.com/t%' GROUP BY url ORDER BY COUNT( url ) desc LIMIT 20 "; $resddrdddddddddult3 = $DB->query($seleddcddddddtMaidfsdfgnwork);

while ($rdddddodhhdw = mysql_fetch_assoc($resddrdddddddddult3)) { ?>



<tr>


<td class="text-center"> <a href="<? echo $rdddddodhhdw['url']; ?>" target="_blank"> <? $uu= $rdddddodhhdw['url'];
$arrayUrl=explode("/",$uu); $finalPath=$arrayUrl[count($arrayUrl)-1];

preg_match("/\d+/",$finalPath,$matches);


$iiid= $matches['0'];


$dddd34fdf ="select * from news where id ='$iiid' "; $resddrddddddddddult3 = $DB->query($dddd34fdf);

while ($rddddddodhhdw = mysql_fetch_assoc($resddrddddddddddult3)) { echo $rddddddodhhdw['title']; echo ' - ' ;

$dddd34fdf ="SELECT count(*) as total from online_site where `url` LIKE '%$iiid%' "; $resddrddddddddddult3 = $DB->query($dddd34fdf); $data=mysql_fetch_assoc($resddrddddddddddult3); echo '( '.$data['total'].' )';

}?>

最佳答案

select
SUBSTRING_INDEX(SUBSTRING_INDEX( url , '/t', -1), '-', 1) AS links
from online_site
having links<>'http://www.xxx' order by id desc limit 100 ;

关于php - 选择带有单词 mysql 的 url 的 preg_match_all id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38909193/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com