熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> MySQL >> 正文

從一個MySQL的例子來學習查詢語句[1]

2022-06-13   來源: MySQL 

    看看下面的例子
    <php
    $ip = getenv(REMOTE_ADDR
    //echo $ip
    $conn=mysql_connect(iproot****
    mysql_select_db(db$conn)
    $sql=select *from counter where ip=\$ip\
    $result=mysql_query($sql$conn)
    $num=mysql_num_rows($result)
    $count=mysql_query(select*from counter$conn)
    $count=mysql_num_rows($count)
    //echo $num
    //echo $count
    if($num==
    {
    $sum=;
    $count++;
    $sql=insert into counter(ipsumcountdata)values($ip$count
    mysql_query($sql$conn)
    mysql_close($conn)
    //echo $count
    }
    else
    {
    $my=select sum from counter where ip=$ip
    $bbbbbb=mysql_query($my) or die(mysql_error())
    $row=mysql_fetch_Array($bbbbbb)
    @$sum=$row[sum];
    //echo $sum
    $sum++;
    $sql=update counter set sum=$sum where ip=$ip
    mysql_query($sql)
    mysql_close($conn)
    }
    $str_count=strval($count)
    $str_count=Chop($str_count)
    $count_len=strlen($str_count)

[]  []  []  


From:http://tw.wingwit.com/Article/program/MySQL/201311/29753.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.