zoukankan      html  css  js  c++  java
  • 一个小的投票系统

    文件http://files.cnblogs.com/files/liuwenbohhh/vote.zip

    index.php

    <!DOCTYPE html Public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <link rel="stylesheet" type="text/css" href="issue.css" />
    <title>控制台</title>
    </head>
    <body>
    <div id="main">

    <?php
    $con = mysql_connect("localhost","root","");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("vote", $con);

    $result = mysql_query("SELECT * FROM vote_user");

    while($row = mysql_fetch_array($result))
    {
    echo "<div class="box">
    <div class="content_left">
    <img src="" alt="" />
    </div>
    <div class="content_center">
    <div class="fig_first">s</div>
    <div class=fig_second">".$row['name']
    ."</div>
    <div class="fig_third">人*4</div>
    </div>
    <div class="content_right">
    <div class="fig_first">s</div>
    <div class="fig_second">s</div>
    <div class="fig_third">
    <a href="update.php?id=".$row['id']."" class="input_zu">投票</a>
    </div>
    </div>
    </div>";

    }

    mysql_close($con);
    ?>
    </div>
    </body>
    </html>

    update.php

    <?php
    function isDiffDays($last_date,$this_date){

    if(($last_date['year']===$this_date['year'])&&($this_date['yday']===$last_date['yday'])){
    return FALSE;
    }else{
    return TRUE;
    }
    }

    $id=$_GET["id"];
    $con = mysql_connect("localhost","root","");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("vote", $con);
    $result = mysql_query("SELECT * FROM vote_user where id='{$id}'");
    $data=mysql_fetch_assoc($result);

    $number=++$data["number"];
    echo $number;
    mysql_query("UPDATE vote_user SET number = '{$number}'
    WHERE id = '{$id}'");
    $time=time();
    $ip=$_SERVER['REMOTE_ADDR'];
    mysql_query("INSERT INTO vote_ip (id, userid,ip, time)
    VALUES (NULL,'{$id}', '{$ip}', '{$time}')");
    mysql_close($con);

    ?>

  • 相关阅读:
    iPhone控件之UIWebView2
    Xcode 4.1/4.2 免证书(iDP)开发+真机调试
    iPhone控件之UIToolbar
    POJ 2472 ||SDUT 2358 106 miles to Chicago(Dijkstra算法变形)
    POJ 2418 Hardwood Species(二叉排序树)
    POJ 2513 Colored Sticks(字典树 + 并查集 + 欧拉回路)
    HDU 4033 Regular Polygon(几何 + 二分)
    POJ 3191 The Moronic Cowmpouter(二进制的变形)
    POJ 2442 Sequence(堆的应用)
    HDU 4036 Rolling Hongshu(数学+物理应用)
  • 原文地址:https://www.cnblogs.com/liuwenbohhh/p/4451275.html
Copyright © 2011-2022 走看看