Numeric Directory Search problem

Discussion in 'PHP' started by adsegzy, Oct 21, 2010.

  1. #1
    Hello friends,

    I am designing directory pages where companies' names can be searched alphabetically. I created pages for each alphabet and created some link has A | B | C | D | E ..........................X | Y | Z | 0-9

    When the visitor click on any alphabet, he will be taken to the page where companies' names that start with that alphabet are listed. 0-9 will lead to the page where companies' name that start with numbers are listed. I use the code below to get the results from my database.

    $sql = mysql_query("SELECT * FROM $com_name WHERE com_name LIKE 'A%'");
    PHP:
    for A Page

    $sql = mysql_query("SELECT * FROM $com_name WHERE com_name LIKE 'B%'");
    PHP:
    for B Page

    $sql = mysql_query("SELECT * FROM $com_name WHERE com_name LIKE 'C%'");
    PHP:
    for C Page etc

    but when i tried the below for numeric page, it didn't work
    $sql = mysql_query("SELECT * FROM $com_name WHERE com_name LIKE '0%, 1%, 2%, 3%, 4%, 5%, 6%, 7%, 8%, 9%'");
    PHP:
    i also tried
    $sql = mysql_query("SELECT * FROM $com_name WHERE com_name LIKE '0-9%'");
    PHP:
    and
    $sql = mysql_query("SELECT * FROM $com_name WHERE com_name LIKE '0%' OR '1%' OR '2%' OR '3%' OR '4%' OR '5%' OR '6%' OR '7%' OR '8%' OR '9%'");
    PHP:
    what can i do? pls help me
     
    adsegzy, Oct 21, 2010 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    EricBruggema, Oct 21, 2010 IP
  3. sinha.sidhi

    sinha.sidhi Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes you can do this but as you can use also text box and put LIKE and text box value.
     
    sinha.sidhi, Aug 29, 2011 IP