PHP SQL Server
$WD 1=$_post[' wd1 ']; It turns out that.
Sql= "select * from xxx where pr_id like '%". $WD 1. " %'";
//**********************************************************
Now we're going to do it. Input: 123 King
Sql= "select * from xxx where pr_id like '%123% ' and the name like '% King '";
And so on, like above, the user enters a condition that may be multiple: 123 Wang Nan or a
wd1=$_post[' Wd1 ']; Now receive input data,
$split _dir = Split (' [] ', $WD 1);//I want to convert an array
Then the SQL server2000 statement does not know how to write, do not know what I mean to express clearly no, I want to express, ask for answers to ideas,
Sql= "??? ";
Reply to discussion (solution)
Sincerely, will not AH. Ask for advice. Thank you in advance!!
$where = "1=1"; $arr = Array (' col1 ', ' col2 ', ' col3 '); foreach ($split _dir as $key = = $val) {$where. = "and". $arr [$key]. " Like '% '. $val. " %' ";}
$arr is the name of the field that needs to appear in the where, of course, the security aspect of your own control.
This is only a general idea, this is obviously not perfect, because others may enter 123 male king or increase the space between the input, this need you to control
Well.. Thanks, I'll try.
Hey, well ... That's what I wrote.
$WD 1=$_post[' wd1 '];
$split _dir = Split (' [] ', $WD 1);
$arr = Array (' Encode ', ' name ', ' category ', ' model ');
$where 2 = "";
for ($m =0; $m
if ($m = = (count ($split _dir)-1))
{
for ($n =0; $n
if ($n = = (count ($arr)-1)) {
$where 2= $where 2. $arr [$n]. "Like '%". $split _dir[$m]. " %'";
}else{
$where 2= $where 2. $arr [$n]. "Like '%". $split _dir[$m]. " % ' or ';
}
}
$where 2= $where 2. " ";
}else{
for ($n =0; $n
if ($n = = (count ($arr)-1)) {
$where 2= $where 2. $arr [$n]. "Like '%". $split _dir[$m]. " %'";
}else{
$where 2= $where 2. $arr [$n]. "Like '%". $split _dir[$m]. " % ' or ';
}
}
$where 2= $where 2. ") and (";
}
}