TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 02-17-2010, 10:35 AM   #1 (permalink)
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
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is causing Duplicate Entries buildakicker MySQL & Databases 5 07-30-2009 04:00 PM
Img Title Embeded on Image? buildakicker General 3 01-08-2009 01:05 AM
[url] tag automatically grabs site title Runar Feedback 7 11-11-2008 03:29 PM
Duplicate Pagination Dan Feedback 2 02-26-2008 04:15 PM
mod rewrite - how to get title in url? Sam Granger Absolute Beginners 5 10-10-2007 02:58 PM


All times are GMT. The time now is 02:26 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design