sweet-as....

Russ

-----Original Message-----
From: Matthew Nock [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 21, 2002 1:15 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Converting values from text to numerical


Hi Russ,

thanks for the reply ...  if that will evaluate whether a (in this case)
a
text string is an integer or not, then its exactly what I need! :)

if it doesnt work, I will post a more detailed example to the list and
see
what we can come up with! :)

-----Original Message-----
From: Russ [mailto:[EMAIL PROTECTED]]
Sent: Friday, 21 June 2002 3:04 PM
To: Matthew Nock; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Converting values from text to numerical


Matthew:

ummmmm how about using the is_int() function to decide if the value from
your DB is a number or not?

http://www.php.net/manual/en/function.is-int.php

//Do DB extraction stuff to get $val/$vals from DB

if(is_int($val))
{
        echo "This is a number so do numbery type things with it..";
}
else
{
        echo "This aint a number so it must be a string, so do stringy
things with it...";
}

Any good?
Russ

-----Original Message-----
From: Matthew Nock [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 21, 2002 1:00 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Converting values from text to numerical


Hi Russ,

Thanks for the reply.

I was looking more along the lines of having one field, that might store
either a text value (such as the words "Not included"), or a numeric
value,
such as 10.

The using PHP to determine if the value is numeric, perform a function
on it
(such as a calculation) then display the result, otherwise, just display
the
text.



-----Original Message-----
From: Russ [mailto:[EMAIL PROTECTED]]
Sent: Friday, 21 June 2002 2:53 PM
To: Matthew Nock; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Converting values from text to numerical


"is it possible to have PHP covert numbers that are stored as text
strings
back into values it can calculate with?"

Mathew:

You can use PHP to convert these - dependant upon the way you store them
in your DB.
Foe example I sometimes need to store different types of data in the
same field (I suppose you need to do this to, othewise you'd store your
numerical data in another column) like so:

Russ|27|6|Michell (stored as a single string in your table)

This is my first name, age, height, and surname respectively.

You could then just use the explode() function to remove the pipes, and
pick out the values (integers in this case) from the resultant array
that explode() provides you with.

Hope this helps you out some.
Russ

-----Original Message-----
From: Matthew Nock [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 21, 2002 12:43 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Converting values from text to numerical


I am about to build a database of products that will store features fore
ach
product in a separate table.

I need to be able to store both text and numeric values in this table,
but
be able to perform mathmatical functions on the numeric variables.

is it possible to have PHP covert numbers that are stored as text
strings
back into values it can calculate with?


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to