내 상황 : 두 다른 형태가 있습니다. 사용자가 이름/설명으로 제품을 검색 할 수있는 일반적인 검색 양식과 사용자가 위치 (우편 번호 및 도시)별로 제품을 검색 할 수있는 또 다른 양식. MySQL/PHP : 두 개의 개별 검색 양식을 연결
이
내 검색 양식의 HTML입니다 :<form name="searchform" method="post" action="index.php?go" class="searchform">
<input type="text" name="search" value="" placeholder="Suchen..." class="field_search" id="tags">
</form>
이는 내 위치 검색 양식의 HTML입니다 :
<form class="location" method="post" action="index.php?go_location">
<input type="image" src="img/location/location.png" width="30" height="30" id="location_image" title="Ortung aktivieren"/>
<input type="text" size="18" placeholder="PLZ, Ort" name="location" id="location" title="Standort angeben"/>
<input type="image" name="" value="" src="img/location/go.png" width="30" height="30" id="location_submit"/>
</form>
하고 해당 PHP :
if(isset($_POST['search'])){
if(isset($_GET['go'])){
if(preg_match("/[A-Z | a-z]+/", $_POST['search'])){
$input=$_POST['search'];
$currently_searching = true;
//connect to db
$sql="SELECT * FROM table WHERE Name LIKE '%".$input."%' OR Description LIKE '%".$input."%'";
//echo results
}}}}
elseif(isset($_POST['location'])){
if(isset($_GET['go_location'])){
$input_location=$_POST['location'];
$currently_locationing = true;
$sql="SELECT * FROM table WHERE Postcode LIKE '%".$input_location."%' OR City LIKE '%".$input_location."%' OR Combined LIKE '%".$input_location."%' OR Combined2 LIKE '%".$input_location."%'";
//echo results
}}}
자, 개별적으로 작동합니다. 내가 달성하고자하는 것은이 두 형식을 연결하여 이미 특정 문자열 (공통 검색 양식을 통해)을 검색하는 사용자가 위치 검색 양식을 사용하여 주어진 검색 결과와 일치하는 결과로 검색 범위를 좁힐 수있게하는 것입니다 우편 번호 ...
이 메시지가 분명합니다. 다음, 검색 양식 - 사용자가 일반적인 검색 양식을 사용하는 경우
$currently_searching
변수가 있으므로이 변수는 사용자가 위치를 사용 및 사실 경우 "true"로된다 :처럼 뭔가를 생각 그들을 연결 ... 그래서 PHP 문에이 같은 것을 추가하려고 :
비록 작동하지 않습니다. 나는 몇몇 도움 녀석을 평가할 것입니다! 미리 감사드립니다.
이유는 단지 한 형태 대신 2를 사용하지 않는? 2 개의 양식을 1 개의 양식으로 결합 할 수 있으며 제출할 때 위치와 검색 정보를 제출합니다. –
두 양식이 페이지의 두 다른 섹션에있는 두 개의 다른 div에 있기 때문에 두 양식을 결합하는 방법을 모르겠다. html이 영향을받지 않고 어떻게이 작업을 수행 할 수 있습니까 ?? 도움을 주신 덕분에 – Frank