开发者

Dealing with a variable number of input fields

I have some javascript code that generates a开发者_如何学编程dditional input fields. So, I can know how many inputs the user will insert (or I can block the number of clones...)

so I have

$form['input'][0];
$form['input'][1];
$form['input'][2];
and so on. 

First problem

Determine how many $form['input'][]

Is this correct?

for $i=0; $i<$form.length[input][]; $i++ {
 $form['input'][$i];
}

and the query

Second problem

// number of ? must change  
($sql = $db -> prepare("INSERT INTO user (something) VALUES (?, ?)"));

$user = 1;
// problem here. this must change dynamically to the number of inputs for each user.
$sql -> bind_param('iss', $user, $form['input'][0], $form['input'][1]);
$sql->execute();

Any ideas?


Determine how many $form['input']: count($form['input']);.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜