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! Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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.. Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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] Quote Link to comment 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! Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.