多列表入库,临时表读取

<?php

  mysql_connect("localhost","root","");
  mysql_select_db("caiji");
  mysql_query("set names 'GBK'");

?>

 

 

<?php
 include_once("conn.php");


  if($_GET[id]<=60){
  $con=file_get_contents("http://it.sohu.com/7/1002/17/column203661721_32".$_GET[id].".shtml");

  $preg = "#<h1>&middot;<a href='(.*)' target='_blank'>(.*)</a><span>#iUs";

  preg_match_all($preg,$con,$arr);

   foreach($arr[1] as $id=>$v){

   $sql="INSERT INTO `tmp_url` (`id`, `title`, `url`) VALUES (NULL, '".$arr[2][$id]."', '".$v."');";
   mysql_query($sql);


 
     }
  $_GET[id]++;
  echo "<script>location.href='ls.php?id=".$_GET[id]."'</script>";
  }
?>

 

 

<?php

   include_once("conn.php");

   $sql="select * from tmp_url limit 3";
   $q=mysql_query($sql);
   while($row = mysql_fetch_array($q)){
    
  $con=file_get_contents($row[url]);


    echo zz("#<title>(.*)</title>#iUs",$con);

    echo zz("#<!-- 正文 st -->(.*)<!-- 正文 end -->#iUs",$con);

    echo "<hr>";
   }


 
 // $con=file_get_contents($_GET[url]);


 //  echo zz("#<title>(.*)</title>#iUs",$con);

//   echo zz("#<!-- 正文 st -->(.*)<!-- 正文 end -->#iUs",$con);

 
 
 
 
  function zz($preg,$con,$num=1){
  preg_match($preg,$con,$arr);
   return $arr[$num];
  }
?>