我有上一页的值,现在使用此值运行了mysql_query:
$sql = "SELECT $value1, $value2 from table where some_value = $previous_page
$result = mysql_query($sql) or die
$row = mysql_fetch_array($result);
echo $row[$value1, $value2];
在HTML文件中,我有一个输入框,但是当用户看到它时,我想先用$ value1填充此框。我怎样才能做到这一点?
(我可以像上面那样回显多个值吗?)
确保进行检查以查看值是否实际存在以防止错误!
连续,我将运行一个PHP检查,例如:
<?php $name = ($value1 != null) ? $value1 : null; ?>
// This checks if it exists, and either returns the value or nothing if it doesn't exist.
然后在HTML中,我将具有一种形式(新的形式或相同的形式):
<input type="text" name="value1" value="<?php echo $name; ?>" />
<!-- This allows it to either place value in the text box, or does nothing if it doesn't exist. -->
我给您提供了代码,假设您知道如何将其定向到表单等等。我试图尽可能地跳过语义。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句