problem with anchor tag

#1
[eluser]don-wp[/eluser]
hi there
i'm newbie with CI and already have problem that I couldnt find any solution in the forum or user guide
I want to have a dynamic link that get the id of selected row from database because I want to open that row in a new pop up window using jquery but I face with same error with every changes I made in codes.I would be appreciated if any one could solve it.here is my code


the controller
Code:
<?php

class Product extends Controller {
function pro() {
       $this->load->model('Product_model');
        $data['records'] = $this->product_model->pro($id);
        $this->load->view('pro_view',$data);
    }
}

The product_view file
Code:
<table align="center" style="vertical-align: middle; top: 120px;">
        <thead>
            <th>name</th>
            <th>price</th>
        </thead>      
        
        <tbody>
            &lt;?php  foreach($records as $rows) : ?&gt;
            <tr>&lt;?=anchor('product/pro/'.$rows->id,$rows->title) rel=number1;?&gt;
                <td>&lt;?php echo $rows->name; ?&gt;</td>
                <td>&lt;?php echo $rows->price; ?&gt;</td>
            </tr>
            &lt;?php endforeach; ?&gt;
        </tbody>
    </table>

The product_model
Code:
function Pro($id){
     $query = $this->db->get_where('product', array('id'=>$id));
      $ret['rows'] = $query->get()->result();
        return $ret;  
    }

#2
[eluser]ShoeLace1291[/eluser]
Try this:
Code:
&lt;?=anchor('product/pro/'.$rows->id,$rows->title, array('rel' => 'number1'));?&gt;

Your probably getting a php syntax error. The first two parameters of the anchor function are "href" and "title" respectively, title being the text between the tags. To add extra attributes(i.e. onclick, id, and in your case "rel", they need to be stored in an array in the third parameter of the anchor function.

Hope this helped.

#3
[eluser]don-wp[/eluser]
dear shoe thanks for rapid answer I do the exact thing u say but now it echo something strange!!!
this is the out put of anchor tag :
id,$rows->name, array('rel' => 'example1'));?&gt;
before I make the changes that u mentioned me it always give this php error that unknown property::$id is defined ....
thanks again for your kindness. Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.