<?
$id=$_REQUEST["id"];
$query="select * from news where id=$id";
$result=mysql_query($query);
if (!$result)
{
echo "数据库连接不成功,请稍后再试!";
exit;
}
$row=mysql_fetch_array($result);
$numrows=$row[0];
echo "<br><div align=center><font size=4><b>$row[title]</b></font></div> ";
if (empty($row[author])) 
{echo "<br><div align=center>$row[logtime]</div>";}
else
echo "<br><div align=center>(作者:$row[author])$row[logtime]</div>";
  $str=nl2br(htmlspecialchars($row[content]));

echo "<br>   $str<br>";
if (!empty($row[froms])) 
echo "<br><div align=center>文章来源:$row[froms]";

?>

解决方案 »

  1.   

    <?
    $query="select * from news where types=1 order by logtime desc limit 4";
    $result=mysql_query($query);
    if (!$result)
    {
    echo "数据库连接不成功,请稍后再试!";
    exit;
    }
    $row=mysql_fetch_array($result);
    $numrows=$row[0];
    if (empty($row))
    {echo "目前没有数据!";
    }else
     while($row = mysql_fetch_array($result)and ($i<4))
    {echo "<img src='images/pic.gif' width='30' height='15'><a href=opennews.php?id=$row[id]>$row[title]</a>[$row[logtime]]<br>";
    $i++;}


    ?>
      

  2.   

    上面的问题先暂不管了,谁帮我解决一下下面的问题,十分感谢!
                <? 

    $domainname="www.".$domain.$after;
    $PORT=43; 
    $MAX_RETRIES=5; 
    $SLEEP_TIME=2; 
    function Getserver($domain) 

    $Servers=array( 
    "net.cn"=>"whois.cnnic.net.cn", 
    "com.cn"=>"whois.cnnic.net.cn", 
    "cn"=>"whois.geektools.com",
    "net"=>"whois.nsiregistry.net", 
    "cc.cn"=>"whois.nic.cc", 
    "com"=>"whois.nsiregistry.net", 
    "edu.cn"=>"whois.edu.cn", 
    "edu"=>"whois.verisign-grs.net", 
    "gov"=>"whois.nic.gov",
    "biz"=>"whois.biz" ,
    "org"=>"whois.verisign-grs.net",
    "org.cn"=>"whois.cnnic.net.cn",
    "info"=>"whois.afilias.info"
    ); 

    $domain=preg_replace("/^([^\.]*)\.([^\.]*)\./","",$domain);
    return $Servers[$domain]; 


    function connect($Server) 

    global $RETRY,$PORT,$SLEEP_TIME; 
    if ($Server=="") {return(-1);} 
    $retry=0; 
    while ($retry<=$MAX_RETRIES) 

    $ptr=fsockopen($Server,$PORT); 
    if ($ptr>0) 

    return ($ptr); 

    else 

    $retry++; 
    sleep($SLEEP_TIME); 


    return(-1); 
    } function Lookup($domainname) 

    global $result; 
    $server=Getserver($domainname); 
    if (empty($server)) 

    $result="没有与该域名匹配的Whois服务器,是否拼错了?"; 
    return $result; 

    $ptr=connect($server); 
    if ($ptr==-1) 

    $result="无法连接到Whois服务器$server"; 
    return $result; 

    else 

    fputs($ptr, preg_replace("/^([^\.]*)\./","",$domainname)."\015\012"); 
    while (!feof($ptr)) 

    $result .= fgets($ptr,128) . "<br/>"; 

    fclose($ptr); 
    return $result; 
    } } $result=Lookup($domainname); 
    if (strstr($result,No match))   //问题在这里,我想查$result中的内容,如果包含No match这个字段就说明还没有注册。
    {
    echo "对不起,'$domainname'已经有人注册,请换名重新注册!";
     exit;
    }
    else
    { echo "恭喜你,'$domainname'还没有注册!";}
    ?>
      

  3.   

    我不知道判断是否包含的那个函数是什么,strstr是我随便写的?有谁知道吗?或者我上面的又该怎样改才能实现我的目的。谢谢!
      

  4.   

    就用strstr就可以的
    若要忽略大小写可以用正则表达式函数eregi
      

  5.   

    Description
    string strstr ( string haystack, string needle)
    Returns part of haystack string from the first occurrence of needle to the end of haystack. If needle is not found, returns FALSE. If needle is not a string, it is converted to an integer and applied as the ordinal value of a character. 注: This function is case-sensitive. For case-insensitive searches, use stristr().