Table 1 Field 1 Field 2
Get to a value of name
Search Field 1 First if no value, in search field 2: Does anyone have any experience with this?
Reply to discussion (solution)
Table 1 Field 1 Field 2
Get to a value of name
Search Field 1 First if no value, in search field 2: Does anyone have any experience with this?
If field 1 searches for n results, it loops n results, if 1 results are not in the Search field 2, in the value of the Loop field 2.
If there are m fields, you search m times?!
Then you can search through the loop.
No one's going to do this anyway.
In order to judge the next, but it is troublesome point.
If there are m fields, you search m times?!
Then you can search through the loop.
No one's going to do this anyway.
only 2 fields are searched, and 2 fields exit without finding the result.
In order to judge the next, but it is troublesome point.
Do you have any ideas? Swite?
If ... else
If ... else
$n =$_get[' name ']
$sou = "SELECT * from Xclass where Name like '% $n% '";
$ss = $mysqli->query ($sou);
while ($s = $ss->fetch_assoc ()) {
echo $z = $s [' Name '];
}
Determine if z above has value, no value search field 2
if (Isset ($z)) {
$zais = "SELECT * from Xclass where Item1 like '% $n% '";
$zaiss = $mysqli->query ($zais);
while ($sss = $zaiss->fetch_assoc ()) {
echo $zaisou = $sss [' Item1 '];
}
}
$n = $_get[' name ']; $sou [] = "SELECT * from Xclass where name like '% $n% '"; $sou [] = "SELECT * from Xclass where Item1 like '% $n% '; foreach ($sou as $sql) { $rs = $mysqli->query ($sql); if ($rs->num_rows) break;} while ($sss = $rs->fetch_assoc ()) { echo $zaisou = $sss [' Item1 '];}
What do you mean by adding a [] symbol behind the $sou [] variable?
Code it's an array
Correct:
Represents it as an array
An empty array, and then the result of select is assigned to him?
Not the result of a select, it is to assign the SQL string to him.
$arr []= ' xx '; is the index of an element with a value of XX appended to the array from 0,1,2, ... Increasing.