php - URL string from database -


i have foreach loop running all records database , displaying them in list on page. i'm trying have clickable button load page show information list item.

so lists records view button on each one, when click view button load 2nd view , display item clicked, if makes sense

the first view list items:

 <div class="row">                 <div class="col-md-12" style="height: 225px;">             <?php foreach ($posts $webstore): ?>                         <div class="col-md-4 text-center thumbnail1234">                         <?php foreach($webstore['images'] $image) : ?>        <img class="img-responsive"  src="<?php echo $image ?>"/>     <?php endforeach; ?>                         <h3><?php echo $webstore['title']; ?></h3>                          <p>date added: <?php echo date('d-m-y', strtotime($webstore['created'])) ?></p>                          <hr> <a href="<?= site_url("webstore/webstore_large/['id']"); ?>" target="_blank" class="btn btn-primary center-block">view</a>                                              <hr>                     </div> 

which link view:

<div class="row">         <div class="col-md-12">             <?php foreach ($posts $webstore): ?>                 <div class="col-md-5">                     <?php foreach ($webstore['images'] $image) : ?>                         <img class="img-responsive"  src="<?php echo $image ?>"/>                     <?php endforeach; ?>                     <div class="col-md-6">                         <h3><?php echo $webstore['title']; ?></h3>                          <p>date added: <?php echo date('d-m-y', strtotime($webstore['created'])) ?></p>                         <p><?php echo $webstore['content']; ?></p>                     </div>                     <hr>                     <hr>                 </div>             <?php endforeach; ?>         </div>     </div> 

and i'm hoping use controller:

if (!defined('basepath')) exit('no direct script access allowed');  class webstore extends my_controller {  public function __construct() {     parent::__construct();     $this->load->model("post");     $this->load->database();     $this->load->helper("url");   } public function index() {     $this->data['posts'] = $this->post->get_webstore($limit=null, $offset=null); // calling post model method getposts()     $this->data['page_title'] = 'store';     $this->layout("pages/webstore", $this->data); }  function webstore_large() {     $this->db->select['id'];            $this->layout("pages/webstore_page"); }  } 

any here great.

first give href tag

<a href="<?= base_url("webstore/view/$webstore['id']") ?>" target="_blank" class="btn btn-primary center-block">view</a> 

considering id unique column in table.

in webstore controller,

function view($id) {    //write login fetch `$id`'s data database.     //load 2nd view here.  } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -