drj26159 2017-06-03 15:50
浏览 108
已采纳

如何使用PHP选择选项

I'm new here and I'm really sorry if the subject of this ticket do not have to be at this place.

I'm working on a PrestaShop website that use SMARTY. How could I display some products with the choice that a customer done in a select tag?

Can I do this with just PHP + HTML or do I need Javascript?

Here is my code :

<div id="conseil">
    <h1 class="page-conseil">Page de conseil pour PC & PC portable Gamer</h1>
    <h2>Dites nous quel style de Gamer vous ètes, nous nous occupons du reste</h2>
    <div class="selection-gameplay">
        <p class="select-gameplay">Sélectionnez le type de joueur qui vous correspond</p>
        <select class="gameplay">
            <option value="1" selected="selected">Sélectionnez</option>
            <option value="1">Casual (de temps en temps)</option>
            <option value="1">Normal (1 à 2h/jour)</option>
            <option value="1">Régulier (2 à 4h/jour)</option>
            <option value="1">Hard Core (>4h/jour)</option>
        </select>
        <p class="select-gameplay">Sélectionnez vos types de jeux</p>
        <select class="game">
            <option value="1" selected="selected">Sélectionnez</option>
            <option value="1">MOBA & FPS peu gourmand (Counter Strike, LOL, DOTA, Heroes Of The Storm)</option>
            <option value="1">MMORPG (WOW, Blade and Soul), FPS (type overwatch, battlefield 3)</option>
            <option value="1">FPS poussé (Battlefield 1), Aventures</option>
            <option value="1">Tout en Ultra !</option>
        </select>
    </div>
    <div class="validation-btn">
        <button type="button" name="submit" class="validation-game">
            <span>Valider</span>
        </button>
    </div>
</div>

I need to display 3 products that's correspond to the choice of the customer in select when he will hit the validate button.

My PHP's knowledge is not really high, if someone can guide, I don't want especially the answer just a way where I can work on it.

Thanks in advance.

</div>
  • 写回答

2条回答 默认 最新

  • duanhu2414 2017-06-03 16:00
    关注

    You can do it by php Html too, just add form tag for code block you have mention along with name properly to each select. When you click submit button form will be posted and give you array of values in $_POST global array, you can get value of single select by below syntax,

    echo $_POST['game'];

    Here "game" is name of one select form Element.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao