在PHP中存储和检索SELECT选项到数据库 [英] store and retrieve a SELECT option to database in PHP

查看:110
本文介绍了在PHP中存储和检索SELECT选项到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一个具有多个选择的表单

我想存储用户在每个类别上选择的内容,然后按顺序将其存储到数据库中找回它

例如,我有以下选择选项:
Hi
i have a form with more than one selection

i want to store what the user select on each category and then store it to a database in order to retrieve it back

for example i have the following selection options:

<表单操作="one.php" method ="get">
<选择名称="q1">
<选项value ="1"> ; 1</option>
< option value ="2"> 2</option>
< option value ="3"> 3</option>
< option value = "4"> 4</option></select>< br>

< select name ="q2">
< option value ="car"> ; car</option>
< option value ="cat"> cat</option>
< option value ="bus"" bus</option>
</select>
<输入类型=提交">
</form>


我知道如何连接数据库
,但是我想要存储选择的代码
以及如何将其恢复为表单

谢谢
<form action="one.php" method="get">
<select name="q1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select><br>

<select name="q2">
<option value="car">car</option>
<option value="cat">cat</option>
<option value="bus">bus</option>
</select>
<input type="submit">
</form>


I know how to connect to database
but i want the code that will store the selection
and how i can retrieve it back to a form

thanks

推荐答案

有许多教程可以逐步指导您. tizag.com .

There are a number of tutorials which can guide you through them, step-by-step. One of the most notable is tizag.com.

我已经挑选了一些适合您需求的页面:

I have picked out a couple of pages which are specific to your needs:

如何将数据从表单获取到服务器
POST和GET之间的区别
如何将数据插入数据库
如何从数据库中检索数据

How to get the data from the form to the server
The difference between POST and GET
How to insert the data into the database
How to retrieve the data from the database


先前的回应是适当的.作为提议另一种专门用于php形式的资源的替代方法- http://phpforms.net/php-forms.html
The previous response is appropriate. As an alternative to propose another resource that specializes in php form - http://phpforms.net/php-forms.html


这篇关于在PHP中存储和检索SELECT选项到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆