我可以创建一次接受多个输入的表单吗? [英] Can I create a form that accepts multiple inputs at a time?
问题描述
您好我想创建一个一次接受多个输入的表单。我并不担心mySQL命令那些简单且易于修复的问题。
我关注的是用于将数据发送到数据库的实际表单和php代码。
我是否需要创建一个包含不同变量的数组,有什么方法可以创建一个foreach循环,然后减少代码行。 。代码行数是否重要????
我是php的新手我只学习了html和css,而且我从java学到了一些东西, python,现在php .....我专注于掌握PHP我只需要一点指导。
我尝试过:
我已经尝试通过重复使用不同名称的相同代码行进行编码这里是一个片段,所以你知道我的意思..
< input type =textname =name10/>
< input type =textname =amount10/>
A< input type =radioname =type10/>
b< input type =radioname =type10/>
c< input type =radioname =type10/>
代码一遍又一遍地重复
$ name10 = $ _POST ['name10'] $ type10 = $ _POST ['type10'] $ amount10 = $ _POST ['amount10'];
$ sql =INSERT INTO表1(名称,类型,金额)
VALUES('$ name10','$ type10','$ amount10');;
同样处理php代码和sql将每个值输入到表单中......我这样做了吗? ??
name10 =
_POST ['name10']
type10 =
Hello I want to create a form that accepts multiple input at a single time. I'm not worried about the mySQL commands those are simple and easy to fix.
What I am focusing on is the actual form and the php code that will be used to send the data into the database.
Do I need to create an array that will hold the different variables, is there any way I can create a foreach loop that will then reduce the lines of code... Do the number of lines of code matter????
I am new to php I only learned html and css, and I have learned a little from java , python, and now php..... I am focused on mastering PHP I just need a little guidance.
What I have tried:
Well I have tried coding this by repeating the same line of code with a different name here is a snippet so you know what I mean..
<input type="text"name="name10" />
<input type="text" name="amount10" />
A <input type="radio" name="type10"/>
b <input type="radio" name="type10"/>
c <input type="radio" name="type10"/>
The code is repeated over and over again
$name10 = $_POST['name10'] $type10 = $_POST['type10'] $amount10 = $_POST['amount10'];
$sql="INSERT INTO table 1(name, type, amount)
VALUES('$name10', '$type10' ,'$amount10');";
Same deal with the php code and the sql to insert every value input into the form... Am I doing this right???
name10 =
_POST['name10']
type10 =
这篇关于我可以创建一次接受多个输入的表单吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!