SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Mar 2003
    Location
    Florida
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    pulling a range of numbers

    I have a menu page that pulls a page from the db table that will begin with each letter of the alphabet, depending on the choice. The code looks like this:
    /ftp-detail.php?search_column=merchant_name&search_value=z

    If I substitute the number 1 for z it will pull the non aplhabetical items beginning with 1, and 2 will pull 2 etc.

    What I need is the code that will pull ALL the non alphabetical (ie 0-9).
    I've tried every combo, tried range,( /ftp-detail.php?search_column=merchant_name&search_value range = (1-3)

    /ftp-detail.php?search_column=merchant_name&search_value= range (1-3)

    and every conceivable combo in between.

    still no cigar.

  2. #2
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here's something that might help:

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

    you can use the decimal version of ascii text to get the range.

    -rsdl

  3. #3
    SitePoint Member
    Join Date
    Mar 2003
    Location
    Florida
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    no problem pulling number

    I don't think the problem is related to string vs integer recognition as the code will pull the values beginning with numbers as long as you enter just one number at a time. If you enter "1" as in "search_value= "1"" it will pull everything beginning with one. Type two, it will pull the "2's" , Three etc.

    What would pull the one's, two's, and three's in the same query?

    Quote Originally Posted by rsdl
    here's something that might help:

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

    you can use the decimal version of ascii text to get the range.

    -rsdl

  4. #4
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm..i'm not clear on what you're trying to do...are you trying to pull stuff via the first letter? e.g. if you select a, it takes all the values that being with letter a?

    if so, then all you need to do is this:

    after extraction you get $test = blah
    $test[0] would give you b

    of course you'd have to accomodate for uppercased letters

    i hope i got it right this time
    -rsdl

  5. #5
    SitePoint Member
    Join Date
    Mar 2003
    Location
    Florida
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, and perhaps the confusion was because I didn't say that I was pulling the data thru the URL. I have an html page with 27 links (e.g. one for each letter and one "miscellaneous" ). The 26 alphabetical links each pull the the data beginning with their respective letter. The "miscellaneous" is for those data entries that begin with non-letter entries.

    Here's the code again:
    ftp-detail.php?search_column=merchant_name&search_value=z

    ----if a 1 is entered in place of the z on the end it will pull all the entries beginning with one, if 2 then the two's will be pulled etc.

    What will pull the 0,1, 2, 3, 4,5,6,7,8,9 from one query submitted through a link and url like the other 26 queries?
    Like I said, I've tried a zilliontimes (well not literally, but alot).


    Quote Originally Posted by rsdl
    hmm..i'm not clear on what you're trying to do...are you trying to pull stuff via the first letter? e.g. if you select a, it takes all the values that being with letter a?

    if so, then all you need to do is this:

    after extraction you get $test = blah
    $test[0] would give you b

    of course you'd have to accomodate for uppercased letters

    i hope i got it right this time
    -rsdl

  6. #6
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well you can do $search=misc

    then
    PHP Code:
    if ($search=='misc')
    {
      
    // use a for loop where it extracts the first character in a query 
     // convert using ord
     // then use an if statement to match the ord range like 
    if ($chr>=64 AND $chr<=91)
    {
     
    // do stuff
    }
    else
    {}
                 
    }
    else
    {} 
    -rsdl


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •