在PHP中,我需要将变量传递给html输入类型标记。我怎么能通过这个?
我试图传递html标记ID,但没有发生任何事情。
这是我的mysql code
:
include('db_connection.php');
if (isset($_POST['submit1'])) {
$skills = $_POST["skills"];
}
if (isset($_POST['submit1'])) {
$skills = $_POST["skills"];
//print_r($skills);die;
}
$sql ="SELECT * FROM `tbl_master_property` WHERE `name` ='$skills'";
$result=$conn->query($sql);
while( $row = $result->fetch_assoc() ) {
$project[] = $row;
}
foreach ($project as $value) {
$pg_address = $value['pg_address'];
$pg_type = $value['pg_type'];
$pg_owner = $value['pg_incharge_name'];
$pg_mobile = $value['pg_incharge_mobile'];
//print_r($pg_mobile);die;
}
这是我的html code
:
<div class="search">
<label>PG Name</label>
<input type="text" id="pgname" placeholder="Search by PG Name" name="pgname" list="locations" class="searchlocation" />
<button type="submit1" id ="submit1" class="searchButton">
<i class="fa fa-search searchButtonSearch"></i>
</button>
</div>
<script>
$(function() {
$( "#pgname" ).autocomplete({
source: "autocomplete.php"
});
});
</script>
<div class="col-lg-12 form-group">
<label>Address</label>
<input class="border col-lg-12" type="text" name= "address" value="<?php echo $value['pg_address']; ?>" required/>
</div>
<div class="col-lg-12 form-group">
<label>PG Owner Name</label>
<input class="border" type="text" name= "pg_owner" value="<?php echo $value['pg_owner ']; ?> required />
</div>
答案 0 :(得分:0)
这有用吗?
<?php
include('db_connection.php');
if (isset($_POST['submit1'])) {
$skills = $_POST["skills"];
}
$sql ="SELECT * FROM `tbl_master_property` WHERE `name` LIKE '%$skills%'";
$result=$conn->query($sql);
while( $row = $result->fetch_assoc() ) {
$project[] = $row;
}
?>
<form action="" method="post">
<div class="search">
<label>PG Name</label>
<input type="text" id="skills" placeholder="Search by PG Name" name="skills" list="locations" class="searchlocation" />
<button type="submit1" id ="submit1" class="searchButton">
<i class="fa fa-search searchButtonSearch">Search</i>
</button>
</div>
</form>
<?php
foreach ($project as $value) {
$pg_address = $value['pg_address'];
$pg_type = $value['pg_type'];
$pg_owner = $value['pg_incharge_name'];
$pg_mobile = $value['pg_incharge_mobile'];
//print_r($pg_mobile);die;
?>
<script>
$(function() {
$( "#pgname" ).autocomplete({
source: "autocomplete.php"
});
});
</script>
<div class="col-lg-12 form-group">
<label>Address</label>
<input class="border col-lg-12" type="text" name= "address" value="<?php echo @$value['pg_address']; ?>" required/>
</div>
<div class="col-lg-12 form-group">
<label>PG Owner Name</label>
<input class="border" type="text" name= "pg_owner" value="<?php echo @$value['pg_owner']; ?>" required/>
</div>
<?php } ?>
答案 1 :(得分:0)
检查出来
<div class="search">
<label>PG Name</label>
<input type="text" id="pgname" placeholder="Search by PG Name" name="pgname" list="locations" class="searchlocation" />
<button type="submit1" id ="submit1" class="searchButton">
<i class="fa fa-search searchButtonSearch"></i>
</button>
</div>
<script>
$(function() {
$( "#pgname" ).autocomplete({
source: "autocomplete.php"
});
});
</script>
<div class="col-lg-12 form-group">
<label>Address</label>
<input class="border col-lg-12" type="text" name= "address" value="<?php if(isset( $pg_address)) echo $pg_address; ?>" required/>
</div>
<div class="col-lg-12 form-group">
<label>PG Owner Name</label>
<input class="border" type="text" name= "pg_owner" value="<?php if(isset( $pg_owner) )echo $pg_owner; ?> required />
</div>