I would like to display the retrieve data from the database into my input area using a dropdown list also generated from the database. The problem is when a run my code the customername input area is disappearing. Can you help me with these?
Dropdown Note: My Dropdown is working I just included it.
<?php
$connect = mysqli_connect("localhost", "root", "", "xls_db");
?>
<select name="customercode" id="customercode" class="form-control">
<option value="" > -----------Customer Code----------- </option>
<?php
$dd_res=mysql_query("Select DISTINCT customercode from cr18_cust_listing WHERE Status = 'Active' ");
while($r=mysql_fetch_row($dd_res))
{
echo "<option value='$r[0]'> $r[0] </option>";
}
?>
</select>
PHP to display text
<?php
$connect = mysqli_connect("localhost", "root", "", "xls_db");
if(isset($_POST["customercode"]))
{
if($_POST["customercode"] != '')
{
$sql = "SELECT * FROM cr18_cust_listing WHERE customercode = '".$_POST["customercode"]."'";
}
$result = mysqli_query($connect, $sql);
while($r = mysqli_fetch_array($result))
{
?>
<div class="form group has-feedback">
<input class="form-control" type="text" name="accntname" required="required" placeholder="Customer Name" value="<?php echo $r['customername'] ?>"><span class="glyphicon glyphicon-user form-control-feedback"></span><br />
</div>
<?php }
} ?>
Missing Customer Name input Area