简体   繁体   中英

Select value of selectbox, get row from MYSQL and work with result in one file

I have selectbox populate from mysql and I want when I select value of selectbox go to mysql table with ajax get the value of one column by selected value of selectbox and use it in same file...

How its possible? Thanks

index.php

<div class="a">
    <div class="l">
        Štát:
    </div>
    <div class="r">
        <select name="country_" id="country_">
            <?php   
                echo '<option value="0">Zvoľte ... </option>';
                    $query = 'SELECT * FROM postovne';
                    $result = mysql_query($query);
                        while ($row = mysql_fetch_array($result)) {
                            $idC = $row['id'];
                            $land = $row['land'];
                            $priceD = $row['dobierka'];
                            $priceU = $row['ucet'];
                                if ($idC == 1) {
                                    echo '<option value="'.$idC.'" selected>'.$land.'</option>';
                                } else {
                                    echo '<option value="'.$idC.'">'.$land.'</option>';
                                }
                         }
            ?>
        </select>

    </div>
</div>


<script language="javascript" type="text/javascript">
         //some AJAX function
</script>

<div class="a">
     <div class="l">
       Cena:
     </div>
     <div class="r">
        <?php echo $priceD; ?>
     </div>
</div>

您可以看一下我的问题,出于神秘的原因并未在wordpress上为我工作,但它应该可以工作,还可以查看该问题中的聊天会话: https ://stackoverflow.com/q/43800131/7862006它不是在这里获得免费的定制脚本网站,请进行研究,然后尝试,当您失败时(多次)向我们提供概述,也许我们可以帮助您踏上正确的路。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM