-----Message d'origine----- De : Vincent Fievet Envoyé : mercredi 27 août 2003 10:44 À : '[EMAIL PROTECTED]' Objet : problem with a mysql query with data from a form
hi, i am a newbie to php and mysql, i run the easyphp kit ( php 4.2.0, Mysql 3.23.49 and phpmyadmin 2.2.6 ) i would like to use a select * from mytable where my variable like '%$mystring%' where $mystring come from a form <form action="show.php" method="post" name="form1" target="_blank"> <table align="left"> <tr> '%Mike % <td width="98"><h3>Communication Impliquant :</h3></td> <td width="144" valign="middle"> <font color="#FFFFCC"> <select name="det" size="5" id="det"> <option value="PC" selected>PC</option> <option value="echo">echo</option> ... <option value="H10 Tango">H10 Tango</option> </select> <select name="den" size="1" id="den"> <option value=" " selected> </option> <option value="1">1</option> ... <option value="10">10</option> </select> </font></td> <td width="153"> <input name="delibre" type="text" id="delibre" maxlength="20"></td> <td width="39"> <input type="submit" name="Submit" value="Ok"> </td> so ,after choosing "PC" in the form, in show.php i do a $sql="SELECT * FROM journal WHERE a like '% $det%' OR de like '%$det%' order by dateheure desc"; echo $sql; and what i get is : SELECT * FROM journal WHERE a like '%PC %' OR de like '%PC %' order by dateheure desc ( note the blank space at the end of PC ) whitch doesnt get any record since the word i am looking is "PC" and not "PC " i used a "like" because the request should be used to find record with "PC 1" "PC" "PC 9" "PC12" ... any ideas ? Thanx Vincent Fievet