开发者

zend framework:I want to show images. but I can only show image that in most bottom line of DB

This is my first topics in stackoverflow. and Im not native englis开发者_开发问答h speaker.

But I have one biginner's question.Please answer me!

Now I am making simple auction web-site.

So,now I am making product display page.

I want show image,title,auction_endtime.

image's name(string),title,auction_endtime is fetched from DB.

And image's data is fetched from Folder(/auction/img/).

Autually I can show title,auction_endtime,but image is problem.

Only shown image is most bottom line in DB's image.

And that image is shown in every line.

I can't show every image in correct each line.

I tried array_merge title,auction_endtime and image's data.

But I cant use image's data as propper array.

And I tried foreach image's data in View phtml's file.

But I cant use image's data as array.

Please help me.

Thanks a lot!

//This is Controller.

//This is zend_form for using images.

public function indexForm()
{
    $form = new Zend_Form();

    $form->setElementDecorators (
        array (
            'ViewHelper',
            'errors',
            array (
                'decorator' => 'Description', 
                'options' => array (
                    'tag' => 'p', 
                    'class' => 'description'
                )
            ),
            'Label'
       ),
       array ('file' ) );

    return $form;
}


public function indexAction()
{
    $form = $this->indexForm ();
    //image's name(string),title,auction_endtime is fetched from DB.
    $select = $this->db->select()->from('displayDB');
    $result = $this->db->fetchAll($select);
    //This is for fetching image's data by image's name.

    foreach ($result as $key => $value) { 
        $form->addElement (
            'image',
            'submitImage',
            array(
                'width' => 200,
                'height' => 200,
                'value' => '/auction/img/'.$result[$key][file_upload],
                'class' => 'fade'
            )
        );

        //This is for view.

        $this->view->assign ( 'image' , $form );

        $this->view->assign('result',$result);

        }
    }
}




//This is View's phtml file.

<div class="content">

    <table class="list" border="0">

    <?php $image=$this->image; ?>

    //Show in table.

    <?php foreach($this->result as $row): ?>

        <td><?php echo $image; ?></td>

        <td><?php echo $row['title']; ?></td>

        <td><?php echo $row['uTimedata_end']; ?></td>

    </tr>

    <?php endforeach; ?>

    </table>

</div>


Both form elements and view variables requires unique keys. On

    $form->addElement (
        'image',
        'submitImage',
        array(
            'width' => 200,
            'height' => 200,
            'value' => '/auction/img/'.$result[$key][file_upload],
            'class' => 'fade'
        )
    );

You overwrite the element every time this expression is executed. Als on

    $this->view->assign ( 'image' , $form );
    $this->view->assign('result',$result);

the same happens for the view variables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜