CODE-FATHER.COM : 䫵觡觻ѹ 鴷ҡ˹

   
  äҢ㹰ҹ ªͿŴͧù ¾͡ѹҺҧ
觼ҹöҹдǡ Ǵ ж١ͧçͧҡҡкؿ
Ф
 
ѹ֧͹ʹ෤Ԥ Ըա Ѻ
  Ҩ෤Ԥ "෾" 褹ҧ ջѭ
  ҧ繡äҢŹѡ¹ФѺ դҵʹѡ֡ ʡ е¹

ԡٻʹҾҴԧ
 
   
 

ǹͧ


<form name="form1" method="post" action="student.php?show=OK&strSearch=Y">
<table width="100%" >
<tr>
<td width="36%">
<div align="right"> :
<select name="Search2">
     <option value="Student_ID" <? if($Search2=="Student_ID"){ ?>selected<? }?>>ʹѡ֡</option>
     <option value="FirstName" <? if($Search2=="FirstName"){ ?>selected<? }?>></option>
     <option value="LastName" <? if($Search2=="LastName"){ ?>selected<? }?>>ʡ</option>
     <option value="Group_Study" <? if($Search2=="Group_Study"){ ?>selected<? }?>>¹</option>
</select></div>
</td>
<td width="64%">

     <input name="Search" type="text" size="20" value="<? echo $Search?>">
     <input type="submit" name="submit" value="Search"> ʹѡ֡,, ʡ, ¹
</td>
</tr>
</table>
</form>

 

$Search = ÷红ͤҤҤѺ 觤令ǡйӤҵùʴ㹪ͧ
<input name="Search" type="text" size="20" value="<? echo $Search?>"> Ҥ

$Search2 = 繵÷纪Ϳ촷Ҥ 觤令ҡйӵù仵Ǩͺ 鴹

<option value="Student_ID" <? if($Search2=="Student_ID"){ ?>selected<? }?>>ʹѡ֡</option>
<option value="FirstName" <? if($Search2=="FirstName"){ ?>selected<? }?>></option>
<option value="LastName" <? if($Search2=="LastName"){ ?>selected<? }?>>ʡ</option>
<option value="Group_Study" <? if($Search2=="Group_Study"){ ?>selected<? }?>>¹</option>
͡ҵ͹ Ҽ͡ҵ ͤкеǨ

зӡ⿡ Selected

 

* * * 觤ҵ÷ 2 ǹ Һҵͧ ͹ Ѻ

 

 
 


ǹͧä

 

if($strSearch=="Y"){
     $sql="select * from tbl_student Where ".$Search2." like '%".$Search."%' "; // 觤
}else{
     $sql="select * from tbl_student";
}

     $Qtotal = mysql_query($sql);


ͧҡ ˹ ź ˹ǡѹ µͧҧ strSearch

<form name="form1" method="post" action="student.php?show=OK&strSearch=Y">

͹觤仡äҵ

 

 

͸Ժ¤觹Դ֧ФѺ ͤѧ

 

select * from tbl_student Where ".$Search2." like '%".$Search."%'

 

繤͡Ũҡҹ ͹䢤Ѻ Ҽҵ кتͷ ""

Ǥԡ к觤ҵ Search Search2 strSearch=Y

͹䢷 鴢ҧФѺ 鴤 sql ѧѺ ͧ echo $sql

 

select * from tbl_student Where FirstName like '%%'

 


͹ like ͧ Sql Select

- ҵͧäҢŷ鹵鹴 X ٻẺѧѺ like 'X%'

- ҵͧäҢŷŧ´ X ٻẺѧѺ like '%X'

- ҵͧäҢŷСͺ X ( X ˹ ѧ ҧ ) ٻẺѧѺ like '%X%'

   
  ҧúҧѺ ͨͧ ҨҾ
  ͸Ժ´ش ҷö
  ҹ к÷Ѵ ФѺ պ͹
  ҡ㨡ͺʹѺ
   
 

 

 
"Ф ͡觻ѹ С ˭ ҹ"


Ѻ¹ VB6 PHP Ҥᾧ ҧԴ