Jump to content

[SOLVED] how to insert fix character length


TheJuan

Recommended Posts

hi

im wondering if PHP is capable of inserting fix character length in mysql field, and how it be possible or could point me to a article/tutorial related to this.

 

sample.

i have a textbox > Firstname: Glenn

Lastname: Mission

after i submit this data, mysql store this to fld_firstname, fld_lastname as 15 varchar length adding a blank space to the rightside to make it a 15 characters in total

 

i have done forum search and web search but with no luck.

 

more power

In the form element:

maxlength='15'

 

In the post-back code:

$_POST['MY-15-CHAR-FEILD'] = trim($_POST['MY-15-CHAR-FEILD']);

 

AND/OR (this method is a bit more aggressive but the trade off is that it will always be 15 chars)

 

$_POST['MY-15-CHAR-FEILD'] = substr($_POST['MY-15-CHAR-FEILD'], 0, 14);

thanks for the reply

 

i thought trim() removes all whitespace characters from both the left and right ends of a string.

 

what i would like to make is to add a whitespace to a variable firstname, lastname that could make it a 15charachter data field stored in mysql.

 

greatly appreciated

thanks for the reply

 

i thought trim() removes all whitespace characters from both the left and right ends of a string.

 

what i would like to make is to add a whitespace to a variable firstname, lastname that could make it a 15charachter data field stored in mysql.

 

any help

 

Read my post.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.