Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我如何选择在占位符中使用所选名称?_Php_Html_Forms - Fatal编程技术网

Php 我如何选择在占位符中使用所选名称?

Php 我如何选择在占位符中使用所选名称?,php,html,forms,Php,Html,Forms,将此添加到while循环中 在if条件循环中添加所选选项名称或值,并在其中定义vaiable <fieldset> <?php $q3=mysql_query("SELECT * FROM tz_kliendid"); echo "<select name='nimetus' id='nimetus'><option value=''>--- Valige klient ---</option>"; while($f3=mysql_fet

将此添加到while循环中

在if条件循环中添加所选选项名称或值,并在其中定义vaiable

<fieldset>

<?php $q3=mysql_query("SELECT * FROM tz_kliendid"); 
echo "<select name='nimetus' id='nimetus'><option value=''>--- Valige klient ---</option>";
while($f3=mysql_fetch_assoc($q3)){ $klient=$f3['klient']; if($f3['id']==$klient){ $selected = "selected"; $selectedval = $f3['teenus'];} echo '<option value="'.$f3['id'].'" $selected>'.$f3['vnimi'].'-'.$f3['teenus'].'</option>';}echo '</select>'; ?><br />
<input type="button" name="next" class="next action-button" value="EDASI" /><input type="submit" name="register" class="next action-button" value="LISA" /></fieldset>

<fieldset><div class="log"><div class="content2"><div style="text-align:center"><input type="text" name="kogus" placeholder="<?php echo $selectedval; ?>"></div><br />
<input name="to" type="text" class="tcal" placeholder=""></div></div><br />
<input type="submit" name="submit" class="submit action-button" value="KINNITA" /></fieldset></form>
编辑2

将此变量添加到适当的保持架中

$selectedval = '';
while ($f3=mysql_fetch_assoc($q3)) { 
      $klient=$f3['klient']; 
      if ($f3['id']==$klient) { $selected = "selected"; $selectedval .= $f3['teenus'];  }  //add it here
      echo '<option value="'.$f3['id'].'" $selected>'.$f3['vnimi'].'-'.$f3['teenus'].'</option>';
    }

    echo '</select>'; 
请不要在2016年使用mysql。应尽可能使用mysqli_*。
$selectedval = '';
while ($f3=mysql_fetch_assoc($q3)) { 
      $klient=$f3['klient']; 
      if ($f3['id']==$klient) { $selected = "selected"; $selectedval .= $f3['teenus'];  }  //add it here
      echo '<option value="'.$f3['id'].'" $selected>'.$f3['vnimi'].'-'.$f3['teenus'].'</option>';
    }

    echo '</select>'; 
<input type="text" name="kogus" placeholder="<?php echo $selectedval ;  ?>">