Jump to content

Feature Request software


ddofborg

Recommended Posts

Posted

I haven't implemented whether or not you have already voted (until you click on a vote link). Any ideas on creating an SQL query to do this (without having to do a query on each item)? I'll see if I can do something about that.

Posted

an SQL query shouldn't be hard, really. table would look like this

CREATE TB_VOTES

(

ID int UNIQUE NOT NULL,

IP varchar(20),

VOTE bit

)

.. assuming you keep track of votes by the voter's IP.

SELECT * FROM TB_VOTES where @IP_JUST_ENTERED_THE_SITE LIKE IP

or something along those lines.

Posted

I would rather add a field in the database called "entries_voted". Separate the request id's with a , so that the field in the database will look like this: ",1,2,3,4,5," etc. then add:

if(strpos($entries_voted,",".$request_id.",")) $voted=1

or something to the page.

That way, you would have one string for every IP (or user) and only one query every time a user enters the site.

Posted

It's a bitch to connect cookies from various sites, really.

Animorc: The simple SQL way will just give you the IDs and Vote state for every vote you made, which can be used to quickly paint the rows in matching colors.

Posted

chaosblade: What is faster? Retrieving a table, or retrieving a field?

I take it that in your way, there will be one new row for every vote from that IP. In my way, there will be only one row containing all votes for an IP.

I might have misunderstood your syntax though.

Edit: You can easily have an alternate colored list by calling a function like this for every match in the while loop:

function fbg(){

static $bg;

if($bg=="color1")$bg="color2";

else $bg = "color1";

return($bg);

}

...

while(...)

$bg=fbg();

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...