Hello everybody, Need a little help to put variable inside query in php $term = $_POST["keyword"]; $query = 'SELECT * FROM XMLTABLE( \'db2-fn:xmlcolumn("TERM.TERM")/term\' COLUMNS "TERM" VARCHAR (5000) PATH \'term\' , "DEFINITION" VARCHAR (5000) PATH \'definition\' ) AS T Where term like \'%[COLOR=#ff0000][I]how to put variable $term here[/I][/COLOR]%\' '; Code (markup): I've tried \'%$term%\' Code (markup): but no success. Thank in advance
Hi there, try to echo out your $query, do you see the $term appear correctly? %term% should work. You can try to put in execute your SQL query in phpmyadmin as well to see if it's correct. Good luck!
$query="SELECT * FROM XMLTABLE( 'db2-fn:xmlcolumn(\"TERM.TERM\")/term' COLUMNS TERM VARCHAR (5000) PATH 'term' , DEFINITION VARCHAR (5000) PATH 'definition', STANDARD VARCHAR (5000) PATH ' @iso_number ', VERSION VARCHAR (5000) PATH '@version ' ) AS T Where term like '%$term%' "; Code (markup):
Hi there, In your current code, $term = $_POST["keyword"]; echo $term; // you can try to echo term here to see if your term is passed through $query = 'SELECT * FROM XMLTABLE( \'db2-fn:xmlcolumn("TERM.TERM")/term\' COLUMNS "TERM" VARCHAR (5000) PATH \'term\' , "DEFINITION" VARCHAR (5000) PATH \'definition\' ) AS TWhere term like \'%[COLOR=#ff0000][I]term[/I][/COLOR]%\''; echo $query // read your query here before you execute your query Code (markup): Did you get any query error? See what you get?