ÂçÂθ¡º÷¤ò¤¹¤ë¤È¤¥¡¼¥ï¡¼¥É¤Ï£±¤Ä°Ê¾å¤¬Â¿¤¤¤Ç¤¹¡£
¤½¤ì¤ò¥Ç¡¼¥¿¥Ù¡¼¥¹¤ØÁ÷¤ë¤È¤¤Î£Ó£Ñ£Ìʸ¤òºîÀ®¤¹¤ë
¢£¥¡¼¥ï¡¼¥É¤ò¼õ¤±¼è¤ë
$text=$_POST["text"];
¢£¥¡¼¥ï¡¼¥É¤¬ÆþÎϤµ¤ì¤Æ¤ë¤«¥Á¥§¥Ã¥¯
if(strlen($text)>0){
//
Á´³Ñ¥¹¥Ú¡¼¥¹¤òȾ³Ñ¥¹¥Ú¡¼¥¹¤ËÊÑ´¹ $text2=str_replace(" "," ",$text);
//
¥¡¼¥ï¡¼¥É¤ò¶õÇò¤ò´ð½à¤Ëʬ³ä¡¡$array=explode(" ",$text2);
}
¡östr_replace ("¸¡º÷ʸ»úÎó", "ÃÖ´¹¤¨Ê¸»úÎó", "ÂоÝʸ»úÎó");
¡ö explode("¶èÀÚ¤êʸ»ú", "ÇÛÎó¤Î¤¿¤á¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹");¡¡Ê¬³ä¤µ¤ì¤¿Ê¸»úÎó¤ÏÇÛÎó¤È¤·¤ÆÊÖ¤µ¤ì¤Þ¤¹
¢£explode¤Ç¼õ¤±¼è¤Ã¤¿ÇÛÎó¤ò¸µ¤ËSQLʸ¤òºîÀ®
$sql="SELECT ¥Ç¡¼¥¿Ì¾ FROM TABLE̾";
$where="WHERE";
//
for($i=0 ; $i < count($array); $i++){
//
$where.="(¥Ç¡¼¥¿Ì¾ LIKE '%$array[$i]%')";
//ºÇ½é¤ËÀßÄꤷ¤¿$where="WHERE"¤Ë¡Ö.¡×¤ÇÉÕ¤±Â¤¹//
if($i < count($array)-1){
$where .="AND"; //
¥Ç¡¼¥¿¤¬¤Ò¤È¤Ä°Ê¾å¤À¤Ã¤¿¾ì¹ç¤Ï¡ÖAND¡×¤Ç¤Ä¤Ê¤²¤ë}
}
Á´ÂÎ¥µ¥ó¥×¥ë
// put your code here
$text1=@$_POST["text1"];
//
$sql="select productname from products";
//
if(strlen($text1)>0){
//Á´³Ñ¥¹¥Ú¡¼¥¹¤òȾ³Ñ¥¹¥Ú¡¼¥¹¤ËÊÑ´¹¤¹¤ë
$text2=str_replace(" "," ",$text1);
//¥¡¼¥ï¡¼¥É¤ò¶õÇò¤Çʬ³ä¤¹¤ë
$array=explode(" ",$text2);
//ʬ³ä¤·¤¿¥¡¼¥ï¡¼¥É¤ò£Ó£Ñ£Ì¤ËÈ¿±Ç¤¹¤ë
$where="where";
for($i=0;$i
$where.="(productname like '".$array[$i]."')";
if($i
$where.="and";
}
}
}
echo "
¸¡º÷¥¡¼¥ï¡¼¥É¡§".$text1;
echo "
ÁȤßΩ¤Æ¤¿£Ó£Ñ£Ìʸ¡§".$sql.@$where;
?>
¥³¥á¥ó¥È
¥³¥á¥ó¥È¤ÎÅê¹Æ