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

  • Home
  • SEARCH
  • 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 7955977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:51:14+00:00 2026-06-04T03:51:14+00:00

Here is my search function : class Ads extends Controller { public function search($format=’velos’,

  • 0

Here is my search function :

class Ads extends Controller
{
    public function search($format='velos', $cat='occasion', $location='france', $keyword, $page=1)
    {
        if($format == 'velos')
        {
            $query = '`private`=0';
        } else
        {
            $query = '`private`=1';
        }
    $this->images($query, $cat, $location,'MATCH(title) AGAINST ("'.db::escape($keyword).'" IN BOOLEAN MODE)', $page, '%s/%s/%s/'.$keyword.'/%d/', $row[0], $keyword);
    }
}

It’s working fine, when I change the keyword in the URL, everything is okay
But I would like to echo that keyword in the page, I don’t know how ?
I tried

<?php echo $keyword; ?>

But the echo doesn’t return anything. There might be a scope issue, but I’m not sure.

EDIT
Actually the $keyword comes from a search field, but from another class, that’s maybe why I was thinking of a scoping issue

class UserModel extends Model
{
    public function search_form()
    {
    $form = new Form('search_form');

    $form->field('keyword', 'text', array
    (           
        'optional'      =>  true
    )); 
    if($data = $form->validate())
    {
        header('Location: '.WEB.sprintf($data['parts_search'].'/'.$data['category_search'].'/'.$data['location_search'].'/'.$data['keyword'].'/1/'));
    }
    return $form;
    }   
}   

Solution :

It might not be the best solution, but actually the only one I found :

$url = 'http://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$parts = parse_url($url);
$path = $parts['path'];
$keys = explode('/', $path);
echo $keys[4]; // `corresponding to the 4th url word`
  • 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-04T03:51:16+00:00Added an answer on June 4, 2026 at 3:51 am

    I’m having some trouble understanding exaclty what the problem is, but based on your proposed solution, there is an auto-loaded CI class that can do what you’ve proposed.

    http://codeigniter.com/user_guide/libraries/uri.html

    So, for
    http://yoursite.com/format/cat/location/yourKeyword

    $keyword = $this->uri->segment(4); // get the 4th segment of my CI URI
    echo $keyword; // prints yourKeyword
    

    Hope this helps.

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

Sidebar

Related Questions

Here is my helper class class Zend_View_Helper_CommonArea extends Zend_View_Helper_Abstract { public function commonArea() {
Anyone know why: class Booking extends Controller { function booking() { parent::Controller(); } function
I need to make a synonym search function, using MySQL. Here is the tables
Here's my URL: https://maps.googleapis.com/maps/api/place/search/xml?location;=41.983333,-87.766666&radius;=5000&sensor;=false&type;=doctor&name;=DPM&key;= mykey I get a request denied response. I have activated
Hey everyone I have a basic search function here that allows me to search
I've search here for an answer to this error & I've tried the tips
Had a good search here but can't see anything that gets my mind in
I've had a quick look through telerik's documentation and a search on here hasn't
Here is my code i am using for custom search, <div id=cse-search-form style=width: 100%;>Loading</div>
I infer from Google search results that strings.h (from here ) is for UNIX

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.