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.


<form method="POST" action="choosecake.php">
    <select id="bakeryid" name="bakeryid">
        <option value="">Select</option>
            $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';
    <input type="hidden" value="<?php echo $bakeryid;?>" name="bakeryid"/>
    <input type="submit" value="Submit" name="submit"/>

Recommended Answers

I would recommend using jQuery. It makes using AJAX calls trivial.


Here is a tutorial from Nettuts that might give you an idea.

Jump to Post

All 2 Replies

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 learning and sharing knowledge.