-1

我已经搜索过了,但我不明白为什么这不起作用。

    <input type="radio" name="soort" value="in"  echo ('.$_GET['soort'].'=="in")?"checked":"">In-Company<br />
    <input type="radio" name="soort" value="open" echo ('.$_GET['soort'] . '"=="open")?"checked":">Open inschrijving<br />

这也不起作用:

    <input type="radio" name="soort" value="in"  echo ($soort=="in")?"checked":"">In-Company<br />
    <input type="radio" name="soort" value="open" echo ($soort=="open")?"checked":">Open inschrijving<br />

显然我做错了什么或者我错过了一些东西。

如果有人可以在这里帮助我或将我引向正确的方向。谢谢!!!!

这是整个表格。

 print '<form action="edit_dienst.php" method="post">
    <p><strong>Titel</strong> <textarea name="navigatie" columns="20" rows="5">' . $row['navigatie'] . '</textarea></p>         
    <p><strong>Tekst</strong> <textarea name="tekst" columns="20" rows="5">' . $row['tekst'] . '</textarea></p>
    <input type="radio" name="soort" value="in"  echo ($soort=="in")?"checked":"">In-Company<br />
    <input type="radio" name="soort" value="open" echo ($soort=="open")?"checked":">Open inschrijving<br />
                <input type="hidden" name="id" value="' . $_GET['id'] . '" />
    <input type="submit" name="submit" value="Pas aan!" />
    </form><p></p>';
4

2 回答 2

0

因为我看到'打印',我推断你已经在 php 标签中。你可以下面的脚本。

$soortInChecked = ($soort=="in")?"checked":"";
$soortOpenChecked = ($soort=="open")?"checked":"";

print '<form action="edit_dienst.php" method="post">
    <p><strong>Titel</strong> <textarea name="navigatie" columns="20" rows="5">' . $row['navigatie'] . '</textarea></p>
    <p><strong>Tekst</strong> <textarea name="tekst" columns="20" rows="5">' . $row['tekst'] . '</textarea></p>
    <input type="radio" name="soort" value="in" '.$soortInChecked.' >In-Company<br />
    <input type="radio" name="soort" value="open" '.$soortOpenChecked.' >Open inschrijving<br />
                <input type="hidden" name="id" value="' . $_GET['id'] . '" />
    <input type="submit" name="submit" value="Pas aan!" />
    </form><p></p>';

问题是您在引号内给出了回声。检查 print/echo 的教程以及 php 中单引号和双引号的区别。

于 2013-02-13T13:54:51.673 回答
0
<?php $soort=$_GET['soort']; ?>
<input type="radio" name="soort" value="in"  <?php echo ($soort=="in")?"checked":"" ?>>In-Company<br />
<input type="radio" name="soort" value="open" <?php echo ($soort=="open")?"checked":"" ?>>Open inschrijving<br />
于 2013-02-13T12:40:47.080 回答