简体   繁体   English

在HTML表单中的输入框旁边输入变量

[英]Puting a variable next to a input box in a HTML Form

For the following code I keep on getting <'Name'> and then an input box next to it. 对于以下代码,我继续获取<'Name'>然后在它旁边的输入框。 All I really want the output to be is Name:(input box). 所有我真正想要的输出是名称:(输入框)。 The <''> is not needed. 不需要<'>。

$inputalt is obviously a variable, below is the array that I am using. $ inputalt显然是一个变量,下面是我正在使用的数组。

     //name values for text input fields
     $inputlist = array("fName" => "First Name", "lName" => "Last Name", "email" => "Email", "phone" => "Phone", "ShoeSize" => "ShoeSize");

This is the piece of code I am having trouble with. 这是我遇到问题的一段代码。

   <?php
     foreach($inputlist as $inputname => $inputalt){
        if(!isset($$inputname)){
            $$inputname = "";
        }

        echo "<'$inputalt'> <input type='text' name='$inputname' value='" . $$inputname . "'/>";

您不需要单引号和<>符号。

echo "$inputalt <input type='text' name='$inputname' value='$inputname'/>";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM