Home > Archive > PHP Language > May 2006 > Replacing
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Hugh Janus 2006-05-17, 3:58 am |
| Hello.
In the database we have to identify people is 3 letters followed by 4
numbers eg. ABC1234 . What I want to do is in a code is remove the ABC to
just leave the 1234.
what I have is
$calls = mysql_result ($rec,$i,"Callsign");
now what I want is.
$pid = HERE THE CODE FOR REMOVING LETTERS
any help or suggestions?
Thanks,
BW
| |
| Gnutt Halvordsson 2006-05-17, 3:58 am |
| Hugh Janus skrev:
> Hello.
> In the database we have to identify people is 3 letters followed by 4
> numbers eg. ABC1234 . What I want to do is in a code is remove the ABC to
> just leave the 1234.
>
> what I have is
>
> $calls = mysql_result ($rec,$i,"Callsign");
>
> now what I want is.
>
> $pid = HERE THE CODE FOR REMOVING LETTERS
>
> any help or suggestions?
>
> Thanks,
> BW
>
>
I would use mysql's substring function
ie.
$query = "SELECT SUBSTRING(id, 3, 4) FROM database"
where the 3 is from where you should start taking the id (how many
letters to skip)
and the 4 is how many letters you should catch.
| |
| Gnutt Halvordsson 2006-05-17, 3:58 am |
| Gnutt Halvordsson skrev:
> Hugh Janus skrev:
>
> I would use mysql's substring function
> ie.
>
> $query = "SELECT SUBSTRING(id, 3, 4) FROM database"
> where the 3 is from where you should start taking the id (how many
> letters to skip)
> and the 4 is how many letters you should catch.
An other option would to use PHP's substr ( string string, int start [,
int length] )
$pid = substr($id, 3, 4);
| |
| Hugh Janus 2006-05-17, 7:58 am |
| Excellent, got it all working now. Thanks alot for the help and quick
response
"Gnutt Halvordsson" <gnutt@shell.linux.se> wrote in message
news:j3Cag.349$E02.243@newsb.telia.net...
> Gnutt Halvordsson skrev:
>
> An other option would to use PHP's substr ( string string, int start [,
> int length] )
>
>
> $pid = substr($id, 3, 4);
| |
| Colin McKinnon 2006-05-20, 6:57 pm |
| Hugh Janus wrote:
> Hello.
> In the database we have to identify people is 3 letters followed by 4
> numbers eg. ABC1234 . What I want to do is in a code is remove the ABC to
> just leave the 1234.
>
<snip>
>
> any help or suggestions?
Normalize your database.
C.
| |
| Hugh Janus 2006-05-21, 7:58 am |
|
"Colin McKinnon"
<colin.thisisnotmysurname@ntlworld.deletemeunlessURaBot.com> wrote in
message news:n4Gbg.1581$bY4.563@newsfe5-gui.ntli.net...
> Hugh Janus wrote:
>
> <snip>
>
> Normalize your database.
>
> C.
errr its not as simple as that, I change that I have to change all of the
scripts.
I have it working from Gnutt's substr suggestion and works perfecly.
|
|
|
|
|