Jump to content
php.lv forumi

html arrays - kā saņemt


aezaurs

Recommended Posts

pieņemsim ka kods ir apmēram tāds:

<form name='name' method='post' action=''>

<input type="text" value="101" name="img_n[1270923017]" />

<input type="text" value="102" name="img_n[1270923016]" />

<input type="text" value="103" name="img_n[1270923015]" />

<input type="submit" value="Ok" name="submit"]" />

</form>

 

problēma sākas tur ka img_n['ir_randoms_skaitlis'].

vērtību vajag insertot iekš db un tur kur lauka vērtība sakrīt ar randomo skaitli

insert into table ('field') values ('101' where field2 = '1270923017');

 

izskatās briesmīgi, nezinu vai tas vispār ir iespējams, gūglē neatradu neko tamlīdzīgu.

Alternatīva ir postot katru lauku atsevišķi, bet nu tad tas ir laikietilpīgi

 

 

Gatavs

if(isset($_POST['submit'])){

include 'include/connect_db.php';

foreach($_POST['img_n'] as $id => $value){

mysql_query('UPDATE img SET i_order = ' . intval($value) . ' WHERE name = '.intval($id));}

}

 

Paldies :)

Edited by aezaurs
Link to comment
Share on other sites

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...