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(
        array(
            '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();
    $num=count($result);
    if($num==0)
    {
        return $this->redirect()->toRoute(NULL, array(
            'controller'=> 'nma',
            'action' => 'index'
        ));
    }
    else
    {
            $result    = $statement->execute();
            $selectData = array();
            foreach ($result as $res) {
                   $selectData[]=$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:

<th>City:</th>
<td>

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

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

ps1907
111

closed 15 Jul '15, 18:03

Oksana%20Serdyuk's gravatar image

Oksana Serdyuk ♦♦
1.5k16

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

By RSS:

Answers

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

Tags:

×2

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