CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 php? for integer to string in mysql select

Print topic Send  topic

Author Message
Frank Rocco
Posted: 07/08/2002, 1:49 PM

Hello,

I need to compare the first 3 digits in a integer field in mySQL database.
I coded select * from db where left(fld1,3) = '123'

This fails because fld1 is numeric.

What is the correct syntax in PHP?

Thanks

Frank

Chris Seymour
Posted: 07/09/2002, 11:14 AM

Hi Frank,
I have not tried this yet (I will when I get a minute),
but would this work:

select * from db where left(fld1,3) = 123


Just a thought.


Chris
Alistair McFadyen
Posted: 07/10/2002, 1:14 AM

Hi Frank

I think the php substr() function may be the one you are looking for:

$numberval=1234;
$stringval = strval($numberval);
$stringval = substr($stringval,0,3);
echo $stringval;

The above returns "123", allowing you to pass $stringval into your query.

Hoipe this helps

Alistair McFadyen




"Frank Rocco" <farocco@hotmail.com> wrote in message
news:agcttk$gv6$1@news.codecharge.com...
> Hello,
>
> I need to compare the first 3 digits in a integer field in mySQL database.
> I coded select * from db where left(fld1,3) = '123'
>
> This fails because fld1 is numeric.
>
> What is the correct syntax in PHP?
>
> Thanks
>
> Frank
>
>

Frank Rocco
Posted: 07/15/2002, 9:47 AM

Thanks for the help.
I also did not realize that in PHP, strings are 0 based. Seeing as it is
close to C, should have caught that earlier.

Regards,
Frank


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.