PHP based on condition loop display
$row [Name]eod; }}}?>
The result I want is $row[' id ']== $value check box to "√", other unequal will be displayed directly!
Now the problem is that the check box can be "√", but those who did not hit "√" will not show, if in the Whiel loop add a
echo<<
<>
$row [Name]eod;
Then he would repeat the show;
I hope you guys can do me a favor.
Reply to discussion (solution)
foreach ($authority as $value) { $checked = $row [' id ']== $value? ' Checked ': '; echo<<
<>
$row [Name]eod;}
You only let the program show the same situation, and the program does not show unequal conditions.
if ($row [' id ']== $value) { echo<<
<>
$row [Name]eod; } else{echo<<
<>
$row [Name]eod;}
You only let the program show the same situation, and the program does not show unequal conditions.
if ($row [' id ']== $value) { echo<<
<>
$row [Name]eod; } else{echo<<
<>
$row [Name]eod;}
So that every time we iterate through the array, he repeats it, I tried.
if ($id = = $value) {}else{}
How can this be repeated?
On one condition, either or No.
if ($id = = $value) {}else{}
How can this be repeated?
On one condition, either or No.
Because there's a shield ring in there: the Foreach and while loops
While loop once, foreach loops 4 times because the $authority array has 4 values, only one value in these 4 values is configured with $id, and if you add else in if, then he will be in the same record 3 times if else value
foreach ($mysqlResult as $row) {$hasValue = False;foreach ($authority as $value) { if ($row [' id ']== $value) { $ HasValue = true; } } if ($hasValue) { echo ' yes '; } else{ echo ' no '; } }
For the time being only think of this method, I do not know if there is an improved version
Solve the problem, solve the code as follows, thank the enthusiastic friend reminds
$row [Name]eod;break; }else{$pd = "false";} If End $cc = $cc. $cc;} foreach endif ($pd = = "true") {echo $cc;} Else{echo <<
<>
$row [Name]eod;}} ?>
Moderator of this method, not only will repeat the choice of the mouth will not come out, but still thank you for your Enthusiasm