scott botkins Posted July 30, 2007 Share Posted July 30, 2007 I've created a database for data to be stored. Each one is stored by an id such as 000001 for the first one. However when I run the search on a internet browser and type in the 000001 it shows up as just "1" instead of "000001" so I'm guessing I have the attributes wrong in database. In phpmyadmin for the field id I have it set for TEXT and not null, do you know what it should be set to fix this error? Thanks! Quote Link to comment Share on other sites More sharing options...
Illusion Posted July 30, 2007 Share Posted July 30, 2007 Try this $id=$_POST['id']; while(strlen($id)==5) { $id="0".$id; } but it is only one of the possible solultion. Quote Link to comment Share on other sites More sharing options...
fenway Posted July 31, 2007 Share Posted July 31, 2007 I've created a database for data to be stored. Each one is stored by an id such as 000001 for the first one. However when I run the search on a internet browser and type in the 000001 it shows up as just "1" instead of "000001" so I'm guessing I have the attributes wrong in database. In phpmyadmin for the field id I have it set for TEXT and not null, do you know what it should be set to fix this error? Thanks! 1) Why do you care how the DB stores this? 2) It should never be TEXT, but rather UNSIGNED INT. 3) If you really care (and you don't) you can use ZEROFILL. 4) You can make it as pretty as you like on the way out, don't mess up the internal DB storage. 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.