2

I started to learn Zend in 3 days ago and got stuck. I have a table sample table like this in view.phtml

<thead>
            <tr>
                <th>ID</th>
                <th>Name</th>
                <th>Email</th>
                <th>Address</th>
                <th>Status</th>                   
            </tr>
        </thead>

and in model.php

public function listallemail() {
        $db = $this->getDefaultAdapter();
        $query = $db->select()
                ->from('members','email');
        return $db->fetchAll($query);
    }

now i have list all the email from mysql database and I want to insert only into the <th>Email</th> with the other column leave blank. Can anyone suggest the way for me to do that

1 Answer 1

1

You should return the data to the controller and then pass the data to the view. Since you haven't provided any extra details I am going to guess you application structure

controller

class Default_IndexController extends Zend_Controller_Abstract
{ 
    public function viewAction()            
    {                                                           

        ...
        $this->view->emaildetails = $modelObj->listallemail();
    }

}

Model

public function listallemail() {
        $db = $this->getDefaultAdapter();
        $query = $db->select()
                ->from('members','email');
        return $db->fetchAll($query);
    }

view.phtml

<thead>
    <?php foreach($this->emaildetails as $email):?>
    <tr>
        <th>ID</th>
        <th>Name</th>
        <th><?php echo $email->email ?></th>
        <th>Address</th>
        <th>Status</th>                   
    </tr>
    <?php endforeach; ?>
</thead>     
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.