dongyong3590 2012-05-24 09:03
浏览 52
已采纳

网址和变量问题

I'm french, so apologize for my English. I've some troubles in my zend application with variables in URLs. I'm creating a back-office application for Hotel's services.

Explication :

I've to set a table with user's information like "id, name, first name etc..." The admin can delete some users when he clicks on "delete" button.

Because i'm a new ZF user, I learned how to send variables from "views" to "controllers"

My views :

I've set the variable transfer with this command.

<?php echo $this->url(array('controller'=>'moderation','action'=>'supprimer' , 'id' => $donnees['id']));?>">

It's works fine, my variables is in my "supprimerAction", it's cool. My URL is like localhost/moderation/supprimer/id/2

BUT, just after, when i'm clicking in another link, to change the controller, my variables are STILL in my URL like localhost/welcome/id/2

i don't know why...

To resolve this problem, I've created another new page, with another controller etc...etc..., it's the same things. My variables are still showed in my url...

I don't know if you understand what my problem is but i worked on it since 2 days...

My codes :

Moderation.phtml

 while ($donnees = $this->reponse->fetch())
         {
           if ($donnees['hotel_zone'] == 0)
              $donnees['hotel_zone'] = "Paris";
           else
              $donnees['hotel_zone'] = "Province";
              ?>
            <tr>
                  <td style="border-top:1px solid grey"> <?php echo $donnees['id'];?></td>
                    <td style="border-top:1px solid grey"> <?php echo $donnees['hotel_name'];?></td>
                    <td style="border-top:1px solid grey" ><?php echo $donnees['id_availpro'];?></td>
                    <td style="border-top:1px solid grey" ><?php echo $donnees['c_name'];?></td>
                    <td style="border-top:1px solid grey" ><?php echo $donnees['c_email'];?></td>
                    <td style="border-top:1px solid grey" ><?php echo $donnees['c_url'];?></td>
                    <td style="border-top:1px solid grey" ><img src="<?php echo $this->baseUrl;?>/public/css/yes.gif"></td>
                    <td style="border-top:1px solid grey" ><a href="<?php echo $this->url(array('controller'=>'moderation','action'=>'supprimer' , 'id' => $donnees['id']));?>"><img src="/public/img/no.png"></a>
              </tr><?php
         }

ModerationController :

<?php
class ModerationController extends Zend_Controller_Action 
{
   /*function init(){ $this->view->baseUrl = $this->_request->getBaseUrl(); }*/

function indexAction()
{

   //echo $this->getRequest()->getParam('id');

      try
     {
        $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
        $bdd = new PDO('mysql:host=myloocalhost;dbname=fhg_bo', 'root', '', $pdo_options);
     }
     catch (Exception $e)
     {
             die('Erreur : ' . $e->getMessage());
     }
     $this->view->reponse = $bdd->query('SELECT id, hotel_name, hotel_city, hotel_zone, c_title, c_name, c_fname, id_availpro, c_email, c_phone, c_url FROM nouveau_client');
      $this->view->nb_mod = $bdd->query('SELECT COUNT(*) FROM nouveau_client GROUP BY id');
}
function supprimerAction ()
{
   echo $this->getRequest()->getParam('id');
}
}
?>

So when i'm receiving this variables and when i'm clicking on another link, my variables are still in my url... It's like variables are memorized in my program....

Thanks for helping me,

And again, sorry for my English, i'll do my best for answering questions.

Thanks

  • 写回答

1条回答 默认 最新

  • dongmeba4877 2012-05-24 09:12
    关注

    You have to add more Parameters to the URL View Helper:

    <?php echo $this->url(array(
            'controller'=>'moderation',
            'action'    =>'supprimer' , 
            'id'        => $donnees['id']), null, true); // true = RESET PARAMS
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划