I have an address dairy project where user can add,delete or update the data. Their is a field called city which is populated from city table in address dairy form.That is working fine, But when I have to edit the data of address diary from addr table as shown below the city field is populated with the cityname which is in addr table and not from city table as shown below.

I need to populated city field from city table with selected value from addr table.

The controller code is as follows:

 $request = $this->getRequest();
$code = $this->getRequest()->getPost('data');

$db = new DbAdapter(
            'driver'        => 'Pdo',
            'dsn'            => 'mysql:dbname=marketdb;host=localhost',
            'username'       => 'root',
            'password'       => 'beeline',

$sql = "SELECT nma_addr.*,cityname,catname FROM nma_addr,city,category WHERE code='".$code."'";
$sql.=" and city.citycode=nma_addr.citycode and category.catcode=nma_addr.catcode";

$sm = $this->getServiceLocator();
    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
    $statement = $dbAdapter->query($sql);
    $result    = $statement->execute();
        return $this->redirect()->toRoute(NULL, array(
            'controller'=> 'nma',
            'action' => 'index'
            $result    = $statement->execute();
            $selectData = array();
            foreach ($result as $res) {
$form = new NmaForm($dbAdapter);
//$viewModel = new ViewModel(array('form' =>$form));
                return new ViewModel(array(
                       'selectData' => $selectData,
                       'form' =>$form,


And my view file is as:


<select name="city" id="city"><option value="1"><?php echo $val['cityname'];?></option>

Here in the select tag I want data form city table but selected value from addr table.How will I be able to achieve this.?

alt text

asked 15 Jul '15, 13:38

ps1907's gravatar image


closed 15 Jul '15, 18:03

Oksana%20Serdyuk's gravatar image

Oksana Serdyuk ♦♦

This forum is for ABBYY SDK users.

(15 Jul '15, 18:07) Oksana Serdyuk ♦♦

The question has been closed for the following reason "Question is off-topic or not relevant" by Oksana Serdyuk 15 Jul '15, 18:03

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 15 Jul '15, 13:38

Seen: 427 times

Last updated: 15 Jul '15, 18:07

© 2016 ABBYY. All rights Reserved. www.ABBYY.com | Privacy Policy | Legal