7/23/19

How do I set the selected item in a drop down box | PHP





<!-- Record set Code -->
<?php
if (isset($_POST['submitSearch'])) {
    include_once 'includes/dbh.inc.php'; // Database Connection

    $searchh = mysqli_real_escape_string($conn, $_POST['searchh']);

    $sqlFormSearch = "SELECT * FROM exchange_order WHERE cus_ac_code = '$searchh';";
    $resultt = mysqli_query($conn, $sqlFormSearch);
    $rowCus = mysqli_fetch_assoc($resultt);
    $queryResultt = mysqli_num_rows($resultt);
}
?>


<!-- Search box -->
<div class="search-box pull-left">
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
<input type="text" name="searchh" placeholder="Search..." required>                                
<button type="submit" name="submitSearch" style="margin-left:0.5rem;" class="btn btn-primary btn-rounded">Search</button>
</form>
</div>


<!-- Select Field Code -->
<div class="form-group">
<label class="col-form-label">Type of Bill</label>
<select name="type_of_bill" class="custom-select">
<option>Open this select menu</option>
<option value="1" <?php if (!(strcmp("1", $rowCus['type_of_bill']))) {
echo "selected=\"selected\"";
} ?>>One</option>
<option value="2" <?php if (!(strcmp("2", $rowCus['type_of_bill']))) {
echo "selected=\"selected\"";
} ?>>Two</option>
<option value="3" <?php if (!(strcmp("3", $rowCus['type_of_bill']))) {
echo "selected=\"selected\"";
} ?>>Three</option>
</select>
</div>


<!-- Text Field Code -->
<div class="form-group">
<label for="example-text-input" class="col-form-label">XO No.</label>
<input name="xo_no" class="form-control" type="text" value="<?php echo $rowCus['xo_no']; ?>" id="example-text-input" required>
</div>


No comments:

Post a Comment

About

Hi, I'm Najathi.
I've started entrepreneurial company, Twin Brothers.Inc.
One is self-funded & the other is venture backed. I also send a weekly. where I share relevent, curated links.

Every Week I Publish a short post on writing, publishing, or content of IT Related

Contact Form

Name

Email *

Message *