Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9095917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:43:18+00:00 2026-06-16T23:43:18+00:00

I need to add link to my gridview this link will call action with

  • 0

I need to add link to my gridview this link will call action with parameters like
user_id and course_id .
so i wrote this code

View :

<?php
$cmodel=new Courses;

$user_id=intval($_GET['user_id']);



$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'courses-grid',
    'dataProvider'=>$cmodel->searchCources($user_id),
    'filter'=>$cmodel,
    'columns'=>array(
        'course_id',
        'name_ar',
        'name_en',
        'code',
        't_time',
        array(
            'name'  => 't_time',
            'value' => "CHtml::link('Add',array('packages/add','user_id'=>$user_id,'course_id'=>$data->course_id))",
            'type'  => 'raw',
        )
    ,

        /*
        'req',
        'aud',
        'targets',
        'programs',
        'criterion',
        'section_id',
        'acc',
        'en',
        'ar',
        'fr',
        'image',
        */


))); 
?>

Model :

    <?php
...

        public function searchCources($user_id)
{
    // Warning: Please modify the following code to remove attributes that
    // should not be searched.

    $criteria=new CDbCriteria;



    $criteria->compare('course_id',$this->course_id);
    $criteria->compare('name_ar',$this->name_ar,true);
    $criteria->compare('name_en',$this->name_en,true);
    $criteria->compare('code',$this->code,true);
    $criteria->compare('t_time',$this->t_time);
    $criteria->compare('intro',$this->intro,true);
    $criteria->compare('req',$this->req,true);
    $criteria->compare('aud',$this->aud,true);
    $criteria->compare('targets',$this->targets,true);
    $criteria->compare('programs',$this->programs,true);
    $criteria->compare('criterion',$this->criterion,true);
    $criteria->compare('acc',$this->acc);
    $criteria->compare('en',$this->en);
    $criteria->compare('ar',$this->ar);
    $criteria->compare('fr',$this->fr);
    $criteria->compare('image',$this->image,true);
      $criteria->addCondition(' course_id not in ( select course_id from ict_cpackage where user_id='.$user_id.') ');

    return new CActiveDataProvider($this, array(
        'criteria'=>$criteria
    ));
}
...
?>

But return this error :

Undefined variable: data 

1- Why return this error ?
2- how I can access to column value

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T23:43:19+00:00Added an answer on June 16, 2026 at 11:43 pm
    'value' => "CHtml::link('Add',array('packages/add','user_id'=>$user_id,'course_id'=>\$data->course_id))",
    

    You are using "" to quote your string, so you need to escape the $ on $data, so it reads as \$data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't access a element with its href. Like this example, i need add
My Link: http://asdasd.com/*****/****/urunler?kategori=5 I need to add pagination to my page. My Code: $config['base_url']
I need to know how to add an a href link to a div?
Hї! I have wrote test for my application. I need add item to database
I need to add a link over the entirety of a div which contains
I am using GCC, what switches do I need to add to link with
I have a button control. On click of this button I need to add
I need to add a link button control to dropdown list item.is it possible
I would like to use CNF in my RCP application, but I need add
I need to add https://www.php.net/xsl this module to my PHP but I'm really confused

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.