Online Polls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



OK! now I am attempting to develop a small online polling system. I set up
my tables and html pages. However, I don't seem to understand how to update
the information in the polling system. I know how to update using sql but
something about this polling system I don't understand. This is my code
below.
My Table Structure
CREATE TABLE poll (

   id int(10) unsigned NOT NULL auto_increment,  //id of the question

   question varchar(255) NOT NULL,  //question

   response1 varchar(255) NOT NULL, //the first possible answer

   response2 varchar(255) NOT NULL, //the second possible answer

   response3 varchar(255) NOT NULL, //the third possible answer

   votes1 int(10) unsigned DEFAULT '0' NOT NULL, //   It is these three I am
having a problem

   votes2 int(10) unsigned DEFAULT '0' NOT NULL, //   putting the data into
when the user clicks the form

   votes3 int(10) unsigned DEFAULT '0' NOT NULL, //  to post their choice.

   date date DEFAULT '0000-00-00' NOT NULL, //date of the poll

   PRIMARY KEY (id)

);


*********** start of code ****************

$db_host = 'localhost';
 $db_user = 'freaknik';
 $db_password = '';
 $db = 'survey';

 $db_srv_conn = mysql_pconnect($dbhost,$db_user,$db_password)
      or die("Could not connect to the server");

 $db_conn = mysql_select_db($db,$db_srv_conn)
              or die("Could not connect to the database");

 //Vote.php

 $submit = $_POST['submit'];
 $response = $_POST['response'];
 if (!$submit)
  {
   echo "kindly click submit";

  }
 else
  {
   echo "u're gett there nik<br>";
   $query = mysql_query("UPDATE survey SET vote=$vote+1 WHERE
response=$response"); //I don't quite understand how to get the correct
response to go into the correct field.

   if (!$query)
    {
     echo "Unable to cast vote";
    }
   else
    {
     echo "Thank you for voting";
    }


  }


?>

*********** end of code *****************
Thanks in advance
Nik

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux