Jump to content
php.lv forumi

Recommended Posts

Posted

Sveiki, Kā lai pareizi savācu POST datus no dinamiski radītiem inputiem

forma kautkā šādi:

<input type="text" name="date[]"><input type="text" name="zina[]">

<input type="text" name="date[]"><input type="text" name="zina[]">

<input type="text" name="date[]"><input type="text" name="zina[]">

u.t.t

 

Vajadzētu izveidot N insertus tabulā

INSERT INTO tabe ('date', 'zina') VALUES ('text', 'text');

Posted (edited)

uztaisi print_r($_POST) un ja kko saproti no masīviem tad gan jau ka sapratīsi kur ir tavi dati ..

+ vēl paskaties par cikliem ... foreach tavā gadījumā

Edited by Klez
Posted
uztaisi print_r($_POST) un ja kko saproti no masīviem tad gan jau ka sapratīsi kur ir tavi dati ..

+ vēl paskaties par cikliem ... foreach tavā gadījumā

 

Ar vienu lauku jau butu vienkārši

foreach($_POST['date'] as $key)

echo $key;

 

bet vairākiem

Posted
$insert = array();
foreach($_POST['date'] as $key=>$value){
 $insert[] = "('".mysql_real_escape_string($value)."','".mysql_real_escape_string($_POST['zina'][$key])."')";
}
if(!empty($insert)){
 mysql_query("UPDATE `tabula` SET (date,zina) VALUES ".implode(", ",$insert));
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...