jwk811 Posted January 5, 2007 Share Posted January 5, 2007 i need to do if "text" is already being used make it text1.. if that is being used make it text2 and so on until it finds a number that is not being used.. thanks for any help! Link to comment https://forums.phpfreaks.com/topic/32923-add-a-higher-number-at-the-end-if-is-taken/ Share on other sites More sharing options...
kenrbnsn Posted January 5, 2007 Share Posted January 5, 2007 Please explain this better. Are you talking about creating new variables? If you are, consider using an array.Ken Link to comment https://forums.phpfreaks.com/topic/32923-add-a-higher-number-at-the-end-if-is-taken/#findComment-153279 Share on other sites More sharing options...
jwk811 Posted January 5, 2007 Author Share Posted January 5, 2007 its an id.. and it will go into the database.. do you understand what im trying to do? Link to comment https://forums.phpfreaks.com/topic/32923-add-a-higher-number-at-the-end-if-is-taken/#findComment-153280 Share on other sites More sharing options...
jwk811 Posted January 5, 2007 Author Share Posted January 5, 2007 it will be like this: 'NAMEyearACCT1'... if that id is being used i want to try NAMEyearACCT2 and if thats being used NAMEyearACCT3.. i pretty sure theres something that will do this easily with php.. Link to comment https://forums.phpfreaks.com/topic/32923-add-a-higher-number-at-the-end-if-is-taken/#findComment-153281 Share on other sites More sharing options...
kenrbnsn Posted January 5, 2007 Share Posted January 5, 2007 If it is an id in a database, make it a number that is set to auto-increment each time a record is inserted.Ken Link to comment https://forums.phpfreaks.com/topic/32923-add-a-higher-number-at-the-end-if-is-taken/#findComment-153282 Share on other sites More sharing options...
jwk811 Posted January 5, 2007 Author Share Posted January 5, 2007 i cant do it that way for what im doing i dont think.. only the end of the id is a number Link to comment https://forums.phpfreaks.com/topic/32923-add-a-higher-number-at-the-end-if-is-taken/#findComment-153283 Share on other sites More sharing options...
jwk811 Posted January 5, 2007 Author Share Posted January 5, 2007 thought i could do something like this exept with a different condition[code][<?php $i=1;while($i<=5) { echo "The number is " . $i . "<br />"; $i++; }?>/code][/code] Link to comment https://forums.phpfreaks.com/topic/32923-add-a-higher-number-at-the-end-if-is-taken/#findComment-153287 Share on other sites More sharing options...
jwk811 Posted January 5, 2007 Author Share Posted January 5, 2007 nevermind i think i got it thanks anyways! Link to comment https://forums.phpfreaks.com/topic/32923-add-a-higher-number-at-the-end-if-is-taken/#findComment-153295 Share on other sites More sharing options...
kenrbnsn Posted January 5, 2007 Share Posted January 5, 2007 Yes, you can do it that way, but you would have to make a query to the database each time you want to store something to determine if the id were already taken. When you use an auto increment field, the number in that field is automatically incremented each time a record is added. You can alway build the id to display from the number in that field.Ken Link to comment https://forums.phpfreaks.com/topic/32923-add-a-higher-number-at-the-end-if-is-taken/#findComment-153297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.