Results 1 to 2 of 2

Thread: coding problem

  1. #1
    Join Date
    Mar 2004
    Posts
    5

    Unanswered: coding problem

    cany anyone help me with this

    Code:
    		if (!empty($name)) { 
                                          if <wotever.entered != <letter*>) {
    			if($q != 0) { $wherequery .= " AND "; } 
    			$q++; 
    			$wherequery .= " name = '" . $name . "'"; 
                                          }
                                          else <wot.ever.entered == <letter*> {
                                          query for names begining with that letter
                                          }
    		}
    where <letter*> can be like a*, b* , c* so it does a query for names beginning with this letter

  2. #2
    Join Date
    Mar 2004
    Posts
    5
    ok had a crack at it, just getting something wrong..

    Code:
    		if (!empty($name)) { 
    			if (!ereg("^[a-z]*$",$name)) {
    				if($q != 0) { $wherequery .= " AND "; } 
    				$q++; 
    				$wherequery .= " name = '" . $name . "'"; 
    			}
    			else {
    				if (ereg("^[a-z]*$",$name)) { 
    					if($q != 0) { $wherequery .= " AND "; }
    					$q++; 
    					$wherequery .= " name LIKE '" . $name% . "'";
    				}
    			}
    		}
    its something in this line i think: $wherequery .= " name LIKE '" . $name% . "'";

    *Edit, so what it meant to do is if user puts in for e.g a* it will find all names beginning with a, otherwise it will just find the name of the product the user put in.

Posting Permissions

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