Jump to content


Photo

noob here pls help


  • Please log in to reply
1 reply to this topic

#1 theoretical_dreamer

theoretical_dreamer
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 30 May 2006 - 02:40 AM

I had a search form but I have to separate the values that was inputted by the user. For example
the user inputs m12ws001. How can I separate this query into 4 separate field in the database?
Example:
mw12ws001 -----> m=branch,12=floor, ws=machine, 001-host number

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 30 May 2006 - 04:45 AM

Assuming they will have always the same number of characters and the same structure, you can use substr()

[a href=\"http://www.php.net\" target=\"_blank\"]http://www.php.net[/a]

$branch = substr($str, 0, 1);
$floor = substr($str, 1, 1);
// et cetera...

~ D Kuang




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users