正在<;中获取数据库值;p>;PHP、MySql中的标签?
我想在html标签中获取数据库值,可以吗??我可以使用此代码在textbox中获取数据库值正在<;中获取数据库值;p>;PHP、MySql中的标签?,php,mysql,Php,Mysql,我想在html标签中获取数据库值,可以吗??我可以使用此代码在textbox中获取数据库值 $con = mysqli_connect("localhost", "root", "", "hct_db"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // escape variables for secu
$con = mysqli_connect("localhost", "root", "", "hct_db"); // Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// escape variables for security
$client_id = mysqli_real_escape_string($con, $_POST['client_id']);
$result = mysqli_query($con, "SELECT * FROM client where client_id = '" . $client_id . "'");
while ($row = mysqli_fetch_array($result)) {
<input class="form-control" name="client_id1" value="<?php echo( htmlspecialchars( $row['address'] ) ); ?>" />
$con=mysqli_connect(“localhost”、“root”、“”、“hct_db”);//检查连接
if(mysqli\u connect\u errno()){
echo“未能连接到MySQL:”.mysqli_connect_error();
}
//安全性的转义变量
$client\u id=mysqli\u real\u escape\u字符串($con,$\u POST['client\u id']);
$result=mysqli_query($con,“SELECT*fromclient,其中client_id=”””);
while($row=mysqli\u fetch\u数组($result)){
是的,你可以这样做。首先,使用查询检索你的数据,并将其保留为一个数组,然后进行回显。是的,你可以试试这个,请在发布问题之前尝试一下
<?php
$con=mysqli_connect("localhost","root","","hct_db"); // Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
} // escape variables for security
$client_id = mysqli_real_escape_string($con, $_POST['client_id']);
$result = mysqli_query($con,"SELECT * FROM client where client_id = '".$client_id."'");
while($row = mysqli_fetch_array($result)) { //this is my retrieve code, what to do next ? ?>
<a href="#"><? echo $row[0]; ?></a> // href tag
<h2><? echo $row[0]; ?></h2> //h tag
<p><? echo $row[0]; ?></p> //p tag
//and so on
<?}?>
试试这个(它会用值填充您的输入框)
迈克尔怎么办?然后在表单字段中添加表单和回显数据。就像这样-?>我想在标签上取,或者标记不在文本框上
<?php
$con = mysqli_connect("localhost", "root", "", "hct_db"); // Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// escape variables for security
$client_id = mysqli_real_escape_string($con, $_POST['client_id']);
$result = mysqli_query($con, "SELECT * FROM client where client_id = '" . $client_id . "'");
echo '<form action="" method="post">';//openning upthe
while ($row = mysqli_fetch_array($result)) {
echo '<p>'.( htmlspecialchars( $row['address'] ) ).'</p>';
}