View Single Post
Old 02-17-2010, 10:35 AM   #1 (permalink)
marxx
The Contributor
 
marxx's Avatar
 
Join Date: Sep 2007
Location: Finland
Posts: 45
Thanks: 3
marxx is on a distinguished road
Default If duplicate title, add rand else, do nothing??

Hi all!

Basic stuff, maybe but I jsut can't figure it out? Can someone help me here?

If duplicate title, add rand numbers, if not duplicate title then do nothing. That's easy but when I need to check if that modifyed title isn't also duplicate I hit the wall..

Here's code (codeigniter):

Code:
$title = $this->input->post('title');
if(this->db->where('title', $title)->get('posts'))
{
  $rand = rand(1000, 9000);
  $title = $title . '-' . $rand;
}

Thanks for all help!
Send a message via MSN to marxx
marxx is offline  
Reply With Quote