0

我的表格编辑:

$params = array (
    'host' => 'localhost',
    'username' => 'root',
    'password' => '',
    'dbname' => 'my_address_book'
);
$db = Zend_Db::factory('PDO_MYSQL', $params);

$stmt = $db->query('SELECT * FROM user WHERE userName LIKE ?', $name2.'%');

while ($row = $stmt->fetch())
{
    $flag1 = 1;
    $id = $row['userId'];

    echo '<table width="300px">';
    echo '
        <tr>
            <th align="left">Name</th>
            <td>:</td>
            <td align="left">'.$row["userName"].'</td>
            <td><a href ="Edit?id ="'.$id.'">Edit</a></td>
        </tr>
    ';
    echo '
        <tr>
            <th align="left">Address1</th>
            <td>:</td>
            <td align="left">'.$row["addressLine1"].'</td>
            <td><a href="Delete?id="'.$row['userId'].'">Delete</a></td>
        </tr>
    ';
    echo '</table>';
}flag1 = 1;

$id = $row['userId'];
echo '<table width="300px">';
echo '
    <tr>
        <th align="left">Name</th>
        <td>:</td>
        <td align="left">'.$row["userName"].'</td>
        <td><a href ="Edit?id ="'.$id.'">Edit</a></td>
    </tr>
';
echo '
    <tr>
        <th align="left">Address1</th>
        <td>:</td>
        <td align="left">'.$row["addressLine1"].'</td>
        <td><a href ="Delete?id="'.$row['userId'].'">Delete </a></td>
    </tr>';
echo '</table>';

在我的编辑控制器中:

if ($this->getRequest()->isPost('$id')){
    $form = new Application_Form_Edit1();
    $this->view->form = $form;  
}

但它永远不会传递给“Edit1”表单。
我对 Zend 真的很陌生。我究竟做错了什么?
任何帮助将不胜感激。

4

2 回答 2

1

尝试$this->getRequest()->getParam('id')代替$this->getRequest()->isPost('id').

if (!empty($this->getRequest()->getParam('id'))){
    $form = new Application_Form_Edit1();
    $this->view->form = $form;  
}

旁注:尝试通过 MVC 标准并将您的 html 推送到视图中。

于 2013-02-18T11:04:37.730 回答
0
if ($this->_request->isPost()) {
      $data = $this->_request->getPost(); //All your data in $data array. print_r($data) it & you will know.
      $id   = (int)$this->_getParam('id'); // get a variable with name = id
}
于 2013-05-21T14:16:27.877 回答