Jump to content

[SOLVED] the $_POST array QUICKIE


Lodius2000

Recommended Posts

Yes.  This works especially well for checkboxes or just multiple items with the same name.  The syntax is:

 

<input name="test[]" type="text" />
<input name="test[]" type="text />

 

Submitting a form with those in it would set $_POST['test'] to an array with both pieces of data from the text fields.

so I want to split apart my post array so i can query the db

 

post looks like this

 

$_POST[1]['word']

$_POST[1]['replace']

 

$_POST[2]['word']

$_POST[2]['replace']

 

where the integer is a row number

 

so to split it apart i use

<?php
foreach ($_POST[] as $word, $replace){
      mysql_query("UPDATE badwords SET word = $word WHERE id={$_POST['id']}");
//repeat for replace
}
?>

 

is that right?

 

thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.