dsrruefh12970 2016-03-10 01:48
浏览 51
已采纳

将段数据从视图传递到控制器,然后传递到新视图

Hi i am using Codeigniter(i am fairly new) and i have a problem displaying data(actually a path from the database) to View B but lets take it from the beggining. I am making a cinema web page and I want a user to click on a link and then get the appropriate redirect to another link which will display the movie that clicked. I am getting the movie name from the database and manage to send it to the Controller B as a parameter and get the image path that i want to display in order to show the picture. But the web page does not show the picture although the path is already sent(i have checked it on Firefox fire bug and to a blank page just to make sure the the path is sent) Btw when i load the page the method and parameter appears on the url but when i delete the parameter and the method from the url and hit enter the path works perfectly displaying the image. Any help?

ps I am a rookie

This is from view a

<div class="movie__images">
   <a href="<?php echo base_url()?>movie_page_full/get_user_click_info/<?php echo $movie_data[6]->title ?>" class="movie-beta__link">
     <img alt='' src=<?php echo $now1 ?>>
   </a>
</div>

This is from controller b

public function get_user_click_info(){

    $this->load->model('movie_page_full_model');

    $decoded_movie_name =  $this->uri->segment(3);


    $query_data = $this->movie_page_full_model->get_single_movie_data($decoded_movie_name);

    $data['path'] = $query_data[0]->path;



    $this->load->view('templates/header');
    $this->load->view('Home/view_movie_page_full',$data);
    $this->load->view('templates/footer_movie_page_full');
}

This is from the view b where i send the path from the controller b

      <div class="col-sm-4 col-md-3 movie-mobile">
              <div class="movie__images">
                  <img alt="" src=<?php echo $path ?>>
              </div>
       </div>

A proof that the path is send to the HTML code but does not show it

The url (Gravity is the name of the movie)

  • 写回答

1条回答 默认 最新

  • duanguochi6194 2016-03-10 20:19
    关注

    I found the answer to my question. I discovered that when i was changing controllers and loading the image, the path was displaying properly but actually it was missing the full url as i was leaving from the homepage that i set as the base url so the only thing that i had to do, was to use the variable that contains the path inside the codeigniter base url. Base url actually appends the rest of missing part. Below is the correct code block.

        <div class="col-sm-4 col-md-3 movie-mobile">
              <div class="movie__images">
                  <img alt="" src=<?php echo base_url($path)?>>
              </div>
       </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测