Stumped

Discussion in 'PHP' started by bigrollerdave, Feb 8, 2007.

  1. #1
    Okay I'm writing a poll script for one of my sites and I have a table setup for the poll. I want to store all the voters in one field but I'm not sure how. This is what I currently have and it doesn't work

    Query to get the random polls
    
    SELECT * FROM  polls  WHERE voters NOT LIKE '$sessuser' ORDER BY RAND() LIMIT 0,1
    
    PHP:
    How I store the voters into the database
    
    $oldvoters = $getvoters['voters'];
    
    //Update Voters With New User
    $newvoters = $oldvoters . ' ' . $sessuser;
    
    //Update database
    mysql_query("UPDATE polls SET voters='$newvoters' WHERE pid='$pid'");
    
    PHP:
    So in the database the voters column will look like this "user1 user2 user3" and so on. There has to be a better way to do this I'm just stumped right now.

    Thanks in advance
     
    bigrollerdave, Feb 8, 2007 IP
  2. designcode

    designcode Well-Known Member

    Messages:
    738
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    118
    #2
    Thats a better way, I also use this type of thing in polling. You can keep users comma separated like,

    user1,user2,user3

    This is a quite good option.
     
    designcode, Feb 8, 2007 IP