vendredi 10 février 2017

php sql dropdown form

Vote count: 0

i am trying to get php dropdown menu to my website but it is not displaying any thing in dropdown its empty as shown in th bilow image . help me to solve this my code is:

<?php
$con=mysql_connect('localhost', '', '')or die("Failed to connect to MySQL: " . mysql_error());

$db=mysql_select_db('')or die("Failed to connect to MySQL: " . mysql_error());
?>

<form>
                        <div class="form-group">


                            <div class="form-control-small">
                                <select id="search_status" name="state" data-placeholder="State">
                                    <option value=""> </option>
                                    <?php
                                        $dd_res=mysql_query("Select DISTINCT state from MyTable");
                                        while($row=mysql_fetch_row($dd_res))
                                        { 
                                        echo "<option value='$row[state]'> $row[state] </option>";
                                        }
                                    ?>

                                </select>
                            </div>

                            <div class="form-control-small">
                                <select id="search_bedrooms" name="dist" data-placeholder="District">
                                    <option value=""> </option>
                                    <?php
                                        $dd_res=mysql_query("Select DISTINCT dist from MyTable");
                                        while($r=mysql_fetch_row($dd_res))
                                        { 
                                        echo "<option value='$row[dist]'> $row[dist] </option>";
                                        }
                                    ?>

                                </select>
                            </div>

                            <div>
                            <button type="submit" class="btn btn-fullcolor">Search</button>
                            </div>
                        </div>
                    </form>

under the state it shows nothing is blank help me to get some details at that position from my database

asked 22 secs ago

Let's block ads! (Why?)



php sql dropdown form

Aucun commentaire:

Enregistrer un commentaire