I have a page which has a form table. It displays select option when an option is selected the user clicks button and it runs choosecake.php which has query for updating. I need the select to be dynamically updated and display the success/error message like "updated" or "no results" on the screen how can I achieve this. Im not very good at ajax could someone guide me please.

displaytable.php

<form method="POST" action="choosecake.php">
    <select id="bakeryid" name="bakeryid">
        <option value="">Select</option>
        <?php
            $sql = "SELECT bakeryid, datefrom FROM cakes";
            $sqlresult = $link->query($sql);
            $sqllist = array();
            if(mysqli_num_rows($sqlresult) > 0) {
                while($row = mysqli_fetch_array($sqlresult))
                {
                echo "<option value=".$row['bakeryid'].">".$row['datefrom']."</option>";
                }
                $sqlencode = json_encode($sqllist);
                echo $sqlencode;
            } else {
                echo 'No Results were found';
            }
        ?>
    </select>
    <input type="hidden" value="<?php echo $bakeryid;?>" name="bakeryid"/>
    <input type="submit" value="Submit" name="submit"/>
</form>

how do pass the select data in data string?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.