php 如何在PHP中创建一个文本框来输出数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25431172/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 17:49:40  来源:igfitidea点击:

How to create a text box in PHP to output data

phphtmlcsstextbox

提问by electricfarts

I am fairly new to PHP and HTML, and I was wondering what kind of css statements is required to generate text box to output a value in one of my PHP functions.

我对 PHP 和 HTML 相当陌生,我想知道需要什么样的 css 语句来生成文本框以在我的一个 PHP 函数中输出一个值。

Currently the function looks looks up data from a SQL server and returns it; however, what I wanted to do is display that data in text box just to confirm that it is grabbing the correct value.

目前,该函数从 SQL 服务器查找数据并返回;但是,我想要做的是在文本框中显示该数据只是为了确认它正在获取正确的值。

Thanks in advance guys!

在此先感谢各位!

回答by MH2K9

Try this

尝试这个

$var = 'your value';
echo '<input type="text" name="name1" value="'.$var.'">';

If you want textarea

如果你想要文本区域

echo '<textarea class="box">'.$var.'</textarea>';

But CSS is used for designing. It depends on yourself how you want to design it. An example for designing the textarea by box class

但是CSS用于设计。这取决于你自己想如何设计它。一个通过box类设计textarea的例子

<style>
    .box{
        border: 1px solid #aaa; /*getting border*/
        border-radius: 4px; /*rounded border*/
        color: #000; /*text color*/
    }
</style>

回答by MBM

Do you need an actual textbox? This is what I use to display php messages.

你需要一个实际的文本框吗?这是我用来显示 php 消息的。

.messagebox {
position:fixed;
background-color:#000000;
color:#ffffff;
border:3px solid #ffffff;
font-family:'Voltaire', sans-serif;
font-size:24px;
width:180px;
border-radius:15px;
z-index:1;
padding:10px;
}

<div class="messagebox">
<?php echo $message ?>
</div>

$message being the variable to echo.

$message 是要回显的变量。