我的表格编辑:

$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>';


在我的EditController中:

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


但是它永远不会传递到“ Edit1”形式。
我真的是Zend的新手。我究竟做错了什么?
任何帮助将不胜感激。

最佳答案

尝试使用$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推送到视图中。

关于php - 如何从URL检索值?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14934271/

10-08 20:32