RE: [PHP-DB] Formatting Strings in MySQL

2001-07-02 Thread Jesse S. Williams

Artur-

No problem.  :-)

Well, you could enter it with the spacing you want by using CHAR(11) instead
of INT(9) or whatever in SQL.  However, depending on how large of a DB this
will be, and how many entries, that's not the optimal way to do it as you
must store to more (null) bytes with every entry, and transfer 2 more (null)
bytes out with every query.  Sure, 2 bytes isn't very much, but I'm a
stickler for smooth code.  The less that NEEDS to be sent, moved or stored,
the better.  The amount of time it takes to format the query afterwards vs.
the time it takes to poll those extra 2 bytes is logically the same, but it
taxes the SQL those few bytes less *shrug*

Either way will work most acceptably.  Otherwise, no, I'm not aware of a
command that will specifically format that way in MySQL.


Jesse Williams
System Administrator
DowNET VoIP Team
Electronic Data Systems


-Original Message-
From: Artur Correia [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 02, 2001 11:37 AM
To: Jesse S. Williams
Subject: Re: [PHP-DB] Formatting Strings in MySQL


Hey,
Thanks in advance for your trouble replying this.
I havent tried it out yet - nor will I untill August. I'm still planning all
this database before I start coding.
This is going to be my first work using mysql/Apache/php4 (it's going to be
a
web based administration tool for a lawfirm (intranet).

Anyway, it sounds good.
As for the string - it's either NULL value or a 9 digit number (initially
the
idea was to format a social security number (in Portugal we have only 9
digits).
Incidentally - i also thought of directly inputing the string formatted into
mysql (I'd rather do this, actually). I've tried using the FORMAT (field,0)
argument, but the output is always comm separated numbers like 123,123,123,
and
this isn't exactly what I had in mind. Do you know of a command in mysql
(either to use with  INSERT or SELECT) that can do this??

Thanks a lot

Artur Correia
Oliveira, Correia & Correia



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Formatting Strings in MySQL

2001-07-01 Thread Jesse S. Williams

Is there a certain format you always need the string in?  Such as 3 digits
followed by a space followed by 3 digits followed by a space followed by 3
digits?  Will there ALWAYS be 9 numbers?  If this is the case, your ereg()
to parse the string and then create a new varible using $regs[x]... so, if
the above example IS the case, you could use:


if (ereg("^([0-9]{3})([0-9]{3})([0-9]{3})$", $initialValue, $regs)  {

   $var = "$regs[1] $regs[2] $regs[3]";
}

This may not be the EXACT code, but it's close... Personally, regexps and I
battle often and they always seem to win  *grumble*  But this should give
you the idea.  Look at:


http://www.phpbuilder.com/columns/dario19990616.php3

or

http://www.php.net/manual/en/function.ereg.php

for more details.  The first is a VERY helpful resource for using regs in
PHP.  Hope this helps some.



Jesse Williams
System Administrator
DowNET VoIP Team
Electronic Data Systems





-Original Message-
From: Artur Correia [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 30, 2001 12:45 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Formatting Strings in MySQL


Hey
How can I get a string (or number) from mySQL like "123123123" to
display "123 123 123"??
Tks
I'm kinda rookie

Artur


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Formatting Strings in MySQL

2001-06-30 Thread Artur Correia

Hey
How can I get a string (or number) from mySQL like "123123123" to
display "123 123 123"??
Tks
I'm kinda rookie

Artur


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]