[英]How do I update the value attribute of a form input with data from variable?
How do I update the value attribute of a form input with data from variable?如何使用变量中的数据更新表单输入的值属性?
Now when the form shows it does not take the data from the variable istead it just autofills: {$title}现在,当表单显示时,它不会从变量 istead 中获取数据,它只是自动填充:{$title}
I tried curly braces and different quatation marks to solve this.我尝试了花括号和不同的引号来解决这个问题。 There is something I am overlooking.
我忽略了一些事情。
for ($i = 0; $i < sizeof($list_array); $i++) {
$title = $list_array[$i]->find('h3', 0)->plaintext;
$price = $list_array[$i]->find('span[class="hz-Listing-price hz-text-price-label"]', 0);
$string = $price;
$clean_string = preg_replace('/[^\d]+/', '', $string);
$integer = intval($clean_string);
$result = $integer / 100;
echo "<li>";
if ($result < 10000 && $result > 2000) {
echo "<p><span style=\"color: green\">$title</span></p>";
echo "<p><span style=\"color: green\">$result</span></p>";
echo
'<div class="container">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4>
Add Contacts
<a href ="index.php" class=" btn btn-danger float-end" > Back</a>
</h4>
</div>
<div class="card-body">
<form action="code.php" method="POST">
<div class="form-group mb-3">
<label for="">First Name</label>
<input name="first_name" <sup>value="{$title}"</sup> class="form-control">
</div>
<div class="form-group mb-3">
<label for="">Phone Number</label>
<input name="phone" value="$result" class="form-control">
</div>
<div class="form-group mb-3">
<label for="">Note</label>
<input type="text" name="note" class="form-control">
<div class="form-group mb-3">
<button type="submit" name="save_contact" class="btn btn-primary">Save contact</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>';
} else {
//echo "<p>$title</p>";
//echo "<p>$result</p>";
}
}
I needed to break into the echo.我需要闯入回声。
I did this by我这样做了
input type="text" name="first_name" value='.输入类型=“文本”名称=“名字”值='。 $title.'
$标题。 class="form-control">
类=“表单控制”>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.