Results 1 to 2 of 2

Thread: help with making poll system dynamic

  1. #1
    Join Date
    Jan 2008
    Posts
    73
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default help with making poll system dynamic

    hi,
    i'm trying to make poll system dynamic but i got stuck somewhere .
    i use:
    http://www.dbscripts.net/poll/

    and mostly i mess with the config.php file.
    this is how the orignal looks like:
    Code:
    $p = new Poll;
    $p->question = "place you'r vote?"; // Question displayed to the user
    $p->returnToURL = "../example.php";    // Specify the URL to return to for this poll; may be relative or absolute
    $p->legend = "title";      // Form legend; leave empty for none
    $p->control_type = $CONTROL_RADIOBUTTONS;  // Control type; $CONTROL_RADIOBUTTONS or $CONTROL_COMBOBOX
    $p->add_value("1", "a");      // Poll value ID and a display string
    $p->add_value("2", "b");
    $p->add_value("3", "c");
    $p->add_value("4", "d");
    $p->add_value("5", "e");
    $VALID_POLLS["1"] = $p;
    and this is what i changed it to:
    (the db connection and table etc work fine):

    Code:
    function connectDB() {
    require "conf.inc";
    @mysql_connect($host,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    }
     
    connectDB();
    $query = "select * from poll";
    $result=mysql_query($query);
    $p = new Poll;
    $p->question = "vote";
    $p->legend = "title";
    $p->control_type = $CONTROL_RADIOBUTTONS;
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    $cityname = $row['cityname'];
    $numofoptions = $row['numofoptions'];
    $options = $row['options'];
    $id2=$row['id'];
    $id2=$id2+1;
    $options2=explode("," , $options);
    $p->add_value($id2-1,$options2[$id2-1]);
     
    }
     
    $VALID_POLLS['$id2-1'] = $p;
     
    mysql_close();
    the error comes from the poll system :"wrong poll id"

    what i miss here?

    thanks in advance

  2. #2
    Join Date
    Jan 2008
    Posts
    73
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    thanks for the links,i will try them.
    i also changed a little my code:
    Code:
    function connectDB() {
    require "conf.inc";
    @mysql_connect($host,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    
    }
    
    connectDB();
    $query = "select * from poll";
    $result=mysql_query($query);
    $p = new Poll;
    $p->question = "עבור מי תצביע בבחירות?(ההצבעה אנונימית)";
    $p->legend = "משאל ראשון";
    $p->control_type = $CONTROL_RADIOBUTTONS;
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    $cityname = $row['cityname'];
    $numofoptions = $row['numofoptions'];
    $options = $row['options'];
    $id2=$row['id'];
    $options2=explode("," , $options);
    for($i=$numofoptions-1;$i>=0;$i--){
    $p->add_value('$i', '$options2[$i]');
    }
    $VALID_POLLS['$id2'] = $p;
    
    }
    
    
    
    mysql_close();
    so now i get empty page.
    i believe the problem is inputting the data from the for loop into the class
    any suggestions on this?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •