i want to change my codigniter url which looks like
http://dev.hello.com/about/updateVision/9 to http://dev.hello.com/about/updateVision/this-is-test-edit/ i have no idea how to make looks like that anyone can help please thanks !
i want to change my codigniter url which looks like
http://dev.hello.com/about/updateVision/9 to http://dev.hello.com/about/updateVision/this-is-test-edit/ i have no idea how to make looks like that anyone can help please thanks !
This all depends on you database structure. I would introduce a field called reference or slug. This will contain a unique string for your record. When creating the record you can use the url_title function to remove spaces as mentioned by @Rooneyl
This reference must be unique so I would create a function that creates a reference in a loop, checks it against the database. When it returns false, it is unique.
public function unique_reference($name)
{
$name = trim(strtolower($name));
$unique_reference = url_title($name);
$counter = '';
do {
$result = $this->db->select('id')
->from('your_table')
->where('reference', $unique_reference)
->get()->row();
if ($result)
$counter++;
$unique_reference = url_title(trim("{$name} {$counter}"));
} while ($result);
return $unique_reference;
}
You can then retrieve record using this unique value