开发者

I want to dynamicly post values in the database from a form. (In PHP and MySQL)

I'm a bit stuck on my code right now.

I've dynamicly made a form, like this:

$r .= '<textarea name="'.$nid.'-'.$cid.'-'.$i.'-1" class="advice" style="width: 800px;">'.$data->advice.'</textarea><br /></p>';

And I want to put whatever the user edits in there, so the value of the text area, in a databa开发者_运维知识库se with, I think as expected, collumns called nid, cid, scid and aid (where $i, and 1 in this case, are scid and aid).

The post variable, print_r'd btw:

Array
(
    [11-1-1-0] => Eengezinswoning (waaronder rijtjeshuis, hoekwoning)
    [11-1-2-0] => Twee-onder-een-kap
    [11-1-3-0] => Vrijstaande woning
    [11-1-4-0] => Appartement (waaronder flat-, boven- of benedenwoning, maisonette) MET LIFT
    [11-1-5-0] => Appartement (waaronder flat-, boven- of benedenwoning, maisonette) ZONDER LIFT
    [11-1-6-0] => Studentenflat met gedeelde keuken en/of badkamer
    [11-1-7-0] => Kamer/studio
    [11-1-8-0] => Seniorenwoning (met of zonder voorzieningen, aanleunwoning)
    [submit] => Opslaan
)

What would be the best approach for this?


If you don't know how many textarea there are you can do a foreach

foreach($_POST as $k=>$v) {
    pdo::prepare("INSERT INTO tbl (?,?)");
    //> Using $k as 11-1-1-0 and $v as the value
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜