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 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致