?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


?
?Re: searching help !!
Author:??(---.sympatico.ca)
Date:???07-29-04 09:59

hi bastien,

how can i compare to an array of car manu., i am really sorry for being so pushy in asking questions, but i really really appreciate your help and advice, and i have to finish this script by this friday, please help.

here is why i got so far, not much different from your example but changed few things:

//input name = q
$search_string = @$_POST['q'];

//check for a space
if(strlen(stristr($search_string, " "))>1){
$list = explode(" ",$search_string);
}
if (count($list)>1){

//handle year
if ((strlen($list[0])==2)&&($list[0]>88)){

//check for 2 digits and value over 88 (ie 1988)
$sql_where = $list[0] . "between year_from and year_to";

//check for 4 digits, ie. q=>1988
}elseif ((strlen($list[0])==4)&&($list[0]>1950)){
$sql_where = substr($list[0],2,4) . "between year_from and year_to";

}else{
$msg = "No car with year was found in the database";
}//end if


//array of car manufacturers
$car_manu[0] = 'Audi';
$car_manu[1] = 'Acura';
$car_manu[2] = 'BMW';
$car_manu[3] = 'Buick';
$car_manu[4] = 'Cadillac';
$car_manu[5] = 'Chevrolet';
$car_manu[6] = 'Chrysler';
$car_manu[7] = 'Dodge';
$car_manu[8] = 'Ford';
$car_manu[9] = 'GMC';
$car_manu[10] = 'Honda';
$car_manu[11] = 'Hyundai';
$car_manu[12] = 'Isuzu';
$car_manu[13] = 'Jaguar';
$car_manu[14] = 'Jeep';
$car_manu[15] = 'Land Rover';
$car_manu[16] = 'Lexus';
$car_manu[17] = 'Lincoln';
$car_manu[18] = 'Mazda';
$car_manu[19] = 'Mercedes';
$car_manu[20] = 'Mercury';
$car_manu[21] = 'Mitsubishi';
$car_manu[22] = 'Nissan';
$car_manu[23] = 'oldsmobile';
$car_manu[24] = 'Plymouth';
$car_manu[25] = 'Pontiac';
$car_manu[26] = 'Saturn';
$car_manu[27] = 'Subaru';
$car_manu[28] = 'Suzuki';
$car_manu[29] = 'Toyota';
$car_manu[30] = 'Volkswagen';
$car_manu[31] = 'Volvo';

?>

?Topics Author? Date
?searching help !!??new
Moses 07-26-04 20:47?
?Re: searching help !!??new
bastien 07-27-04 12:15?
?Re: searching help !!??new
Moses 07-28-04 10:50?
?Re: searching help !!??new
bastien 07-28-04 11:38?
?Re: searching help !!??new
Moses 07-29-04 09:59?
?Re: searching help !!??new
bastien 07-29-04 11:53?
?Re: searching help !!??new
Moses 07-30-04 14:27?
Go to Top??|??Go to Topic??|??Flat View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??wrote: > > hi bastien, > > how can i compare to an array of car manu., i am really sorry > for being so pushy in asking questions, but i really really > appreciate your help and advice, and i have to finish this > script by this friday, please help. > > here is why i got so far, not much different from your > example but changed few things: > > //input name = q > $search_string = @$_POST['q']; > > //check for a space > if(strlen(stristr($search_string, " "))>1){ > $list = explode(" ",$search_string); > } > if (count($list)>1){ > > //handle year > if ((strlen($list[0])==2)&&($list[0]>88)){ > > //check for 2 digits and value over 88 (ie 1988) > $sql_where = $list[0] . "between year_from and year_to"; > > //check for 4 digits, ie. q=>1988 > }elseif ((strlen($list[0])==4)&&($list[0]>1950)){ > $sql_where = substr($list[0],2,4) . "between year_from and > year_to"; > > }else{ > $msg = "No car with year was found in the database"; > }//end if > > > //array of car manufacturers > $car_manu[0] = 'Audi'; > $car_manu[1] = 'Acura'; > $car_manu[2] = 'BMW'; > $car_manu[3] = 'Buick'; > $car_manu[4] = 'Cadillac'; > $car_manu[5] = 'Chevrolet'; > $car_manu[6] = 'Chrysler'; > $car_manu[7] = 'Dodge'; > $car_manu[8] = 'Ford'; > $car_manu[9] = 'GMC'; > $car_manu[10] = 'Honda'; > $car_manu[11] = 'Hyundai'; > $car_manu[12] = 'Isuzu'; > $car_manu[13] = 'Jaguar'; > $car_manu[14] = 'Jeep'; > $car_manu[15] = 'Land Rover'; > $car_manu[16] = 'Lexus'; > $car_manu[17] = 'Lincoln'; > $car_manu[18] = 'Mazda'; > $car_manu[19] = 'Mercedes'; > $car_manu[20] = 'Mercury'; > $car_manu[21] = 'Mitsubishi'; > $car_manu[22] = 'Nissan'; > $car_manu[23] = 'oldsmobile'; > $car_manu[24] = 'Plymouth'; > $car_manu[25] = 'Pontiac'; > $car_manu[26] = 'Saturn'; > $car_manu[27] = 'Subaru'; > $car_manu[28] = 'Suzuki'; > $car_manu[29] = 'Toyota'; > $car_manu[30] = 'Volkswagen'; > $car_manu[31] = 'Volvo'; > > ?> ">??

Provided By
Phorum