0

this code works without an issue...

php script executes from a function.it works without an issue.

<div class="container-md">
    <h4>Add New Job</h4>

    <?php include '../include/alert-form-submission.php'; ?>

    <!-- code here -->
    <div class="row">
        <div class="col-md-4"></div>
        <div class="col-md-4">
            <form action="add-job-controller.php" method="POST">
                
                <?php include '../include/alert-form-submission.php'; ?>

                <div class="form-group">
                    <label for="jobno">Job No:</label>
                    <input type="text" name="jobno" class="form-control" placeholder="Enter Job Number" id="jobno" required>
                </div>

                <div class="form-group">
                    <label for="client">Client:</label>
                     <select name="client" class="custom-select">
                    <option selected>Select Division or District</option>
                        //php code
                     </select>
                </div> 
                <div class="form-group">
                    <label for="letterno">Letter No:</label>
                    <input type="text" name="letterno" class="form-control" placeholder="Enter Letter Number" id="letterno">
                </div>                                                     
                <button type="submit" name="submit" class="btn btn-primary btn-block">Submit</button>   
                </div>                                  

but after i placed below php code,page loads up to that point and populates dropdown from mysql database.but rest of the page won't load.so please help me to fix it

<div class="form-group">
                    <label for="client">Client:</label>
                     <select name="client" class="custom-select">
                    <option selected>Select Division or District</option>


                    <?php
                             $client = new Job();
                             $result = $client->getClient();

                            if ($result->num_rows > 0) 
                            {
                                while($option = $result->fetch_assoc()) 
                                {
                                     echo "<option value=" .$option['id']. ">" .$option['name']. "</option>";                           
                                }
                            } 
                                 $conn->close();
                    ?>


                     </select>
                </div> 
Shadow
  • 33,525
  • 10
  • 51
  • 64
  • Turn on error reporting/display and see what the error is. Is `$conn` set somewhere? [How do I get PHP errors to display?](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display?rq=1) – brombeer Sep 04 '21 at 14:03
  • @brombeer yes.$conn works fine.no error is appearing. – vidyarathna Sep 04 '21 at 14:11
  • I'd place quotes around the `value` part `echo " – brombeer Sep 04 '21 at 14:16

0 Answers0