Welcome Guest, Not a member yet? Register   Sign In
New in codeigniter! poll problem
#1

[eluser]benfike[/eluser]
Hi!
I now work on a poll system.
I make 2 sql table for this:

#vote_answers
-vote_id
-answer_id
-answer
#vote_question
-vote_id
-question
-status('active','inactive','finished')

For Get answers I make an function with this name :
Code:
function getAnswers(){
        $data = array();
        $this->db->where('vote_id', 'vote_question.vote_id');
        $Q = $this->db->get('vote_answers');
        if ($Q-> num_rows() > 0){
            foreach ($Q-> result_array() as $row){
            $data['answer'] = $row['answer'];
        }
        }
        $Q-> free_result();
        return $data;
    }

And only want to list that answer where the vote_answers.vote_id = vote_question.vote_id
How can i do this?

My other problem:
if i make some answers for a Question it list only 1!
Code:
<?php foreach($answers as $answer):?>
            <li>
                &lt;input id="answer_&lt;?php echo $answer['answer_id'] ?&gt;" name="poll_answer_id" type="radio" value="&lt;?php echo $answer['answer_id'] ?&gt;" /&gt;
                <label for="answer_&lt;?php echo $answer['answer_id'] ?&gt;">
                    <strong>&lt;?php echo ($answer['answer']) ?&gt;</strong>
                    (&lt;?php echo $answer['votes'] ?&gt;)
                </label>
            </li>
            &lt;?php
            endforeach;
            ?&gt;


Messages In This Thread
New in codeigniter! poll problem - by El Forum - 08-23-2009, 08:48 AM
New in codeigniter! poll problem - by El Forum - 08-23-2009, 09:57 AM
New in codeigniter! poll problem - by El Forum - 08-23-2009, 12:34 PM
New in codeigniter! poll problem - by El Forum - 08-23-2009, 12:45 PM
New in codeigniter! poll problem - by El Forum - 08-23-2009, 02:11 PM
New in codeigniter! poll problem - by El Forum - 08-24-2009, 12:02 AM
New in codeigniter! poll problem - by El Forum - 08-24-2009, 04:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB