2011-09-15 5 views
0

자동차 용 Oracle 데이터베이스를 검색하는 검색 기능을 생성하려고합니다.PHP 검색 기능

나는 검색 상자 필드를 잡고 데이터를 처리하기 위해 PHP 작업 링크로 보내도록 PHP 스크립트의 페이지에 요청 검색 기능을 넣을 곳을 알고 싶습니다.

<form name:"search" action="http://www.deakin.edu.au/~sjrem/ssss.php" method="post"> 
<h2> Search for a car of your choice </h2> 

<p> 
<table border="0"> 
<tr> 
<td><input type="text" name="search" /> </td> 
</tr> 

</table>     <p> 
<input type="submit" value="Search" /> 
</FORM> 

답변

0

우선 input 요소가 테이블에 있습니까? CSS를 사용하여 위치를 지정하십시오.

둘째, http://www.deakin.edu.au/~sjrem/ssss.php, 당신은 양식이 제출되었습니다 여부를 결정해야합니다 :

if(isset($_GET["search"])) 
{ 
    //Fire up the connection and go to town! 
} 
else 
{ 
    //Do something else. Or not. Whatever floats your boat. 
} 
2

을 첫째로, 당신은 당신의 폼 이름 styntax 수정하려는 :

<form name:"search" 

로를

<form name="search" 

양식에이 필드를 추가하십시오 :

당신의 PHP에서
<input type="hidden" name="action" value="search" /> 

:

if ($_POST['action'] == 'search'){ 
    search(); 
} 

function search(){ 
    $keyword = $_POST['search']; 
    // run your code 
}