>I have a php script that performs a query and then dynamically builds a
>section of a page for every row returned. Each section has some fields and
>three submit buttons. My problem is this. If I make a change to one
>particular section, how can I submit the form passing only the relevant
>section data?

Here are a couple ideas:

1. Have a different <FORM></FORM> for each section.

2. Have only one <FORM></FORM>, but name all the data so that the button and
the 'section' are identifiable.  All the other data is still transmitted,
but you ignore it.

Example of #2:

<FORM>
<?php
  $query = "select foo_id, foo from abc";
  $data = mysql_query($query) or error_log(mysql_error());
  while (list($foo) = mysql_fetch_row($data)){
    echo "$foo<BR>\n";
    echo "<INPUT TYPE=SUBMIT NAME=delete[$foo_id] VALUE='Delete'><BR>\n";
    echo "<INPUT TYPE=SUBMIT NAME=update[$foo_id] VALUE='Update'><BR>\n";
    echo "<INPUT TYPE=SUBMIT NAME=duplicate[$foo_id]
VALUE='Duplicate'><BR>\n";
  }
?>
</FORM>

The "action" part would be something like this:

if (isset($delete)){
  list($foo_id) = $delete; # The foo_id is the key, and the value was
'Delete'
  $query = "select from foo where foo_id = $foo_id";
  mysql_query($query) or error_log(mysql_error());
}
elseif (isset($update)){
  list($foo_id) = $update;
  $query = "update foo set count = count + 1 where foo_id = $foo_id";
  mysql_query($query) or error_log(mysql_error());
}
elseif (isset($duplicate)){
  list($foo_id) = $duplicate;
  $query = "insert into foo(count) select count from foo where foo_id =
$foo_id";
  mysql_query($query) or error_log(mysql_error());
}
  

It's a case of the medium *is* the message, I guess.

-- 
Like Music?  http://l-i-e.com/artists.htm


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to