English 中文(简体)
追踪选民,只允许每个成员1票
原标题:Tracking Votes and only allowing 1 vote per member

我想要做的是,当有人用“一页”表决时,就算选票。 我认为,我失去了试图说明如何追踪某一成员投票的情况。 我似乎无法在某一成员表决时告诉大家。

//Generate code ID
    $useXID = intval($_GET[ id ]);
    $useXrank = $_GET[ rank ];

    //if($useXrank!=null && $useXID!=null) {
        $rankcheck = mysql_query( SELECT member_id,code_id FROM code_votes WHERE member_id=" .$_MEMBERINFO_ID. " AND WHERE code_id=" .$useXID. " );
            if(!mysql_fetch_array($rankcheck) && $useXrank=="up"){
                $rankset = mysql_query( SELECT * FROM code_votes WHERE member_id=" .$_MEMBERINFO_ID. " );
                $ranksetfetch = mysql_fetch_array($rankset);
                $rankit = htmlentities($ranksetfetch[ ranking ]);
                $rankit+="1";
                mysql_query("INSERT INTO code_votes (member_id,code_id) VALUES ( $_MEMBERINFO_ID , $useXID )") or die(mysql_error());
                mysql_query("UPDATE code SET ranking =  ".$rankit."  WHERE ID =  ".$useXID." ");
            }
            elseif(!mysql_fetch_array($rankcheck) && $useXrank=="down"){
                $rankset = mysql_query( SELECT * FROM code_votes WHERE member_id=" .$_MEMBERINFO_ID. " );
                $ranksetfetch = mysql_fetch_array($rankset);
                $rankit = htmlentities($ranksetfetch[ ranking ]);
                $rankit-="1";
                mysql_query("INSERT INTO code_votes (member_id,code_id) VALUES ( $_MEMBERINFO_ID , $useXID )") or die(mysql_error());
                mysql_query("UPDATE code SET ranking =  ".$rankit."  WHERE ID =  ".$useXID." ");
            }
            // hide vote links since already voted
            elseif(mysql_fetch_array($rankcheck)){$voted="true";}
    //}
最佳回答

你们使这一局面变得太困难。 2. 对投票使用数字价值,+1,-1,并对表格实施独一无二的限制:

扩大范围:

create table votes (
  pageId    int references pages (pageId)
 ,memberId  int references members (memberId)
 ,value     int check (value in (-1,1))
 ,constraint votes_unique unique (pages,members)
)

现在,你可以“电算元(价值)......获得用户的物品,以及用页等。

问题回答

象你那样做的事情——只是用所有东西来取代一切形象。

PHP: 星级评级制度概念:

你的第一点是无效的,因为它有两项WHERE条款。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签