select preg_match_all url 的 ID,字词 mysql

select preg_match_all id of url with words mysql

想要使用 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 ;