At 04:40 PM 11/14/2005, Chris Payne wrote:
Hi there everyon,
I have a set of form fields dynamically generated but each item must contain
2 pieces of data - the input from the field AND the id that the input
represents from the DB. I had this info a while back but had a major HD
crash and lost the info I had, how can I do this easily in PHP?
Hopefully an easier to understand scenario:
I have a form with - example - 5 items listed, each item from the DB and you
select ONE item only out of the list, when you submit the form it sends the
input from the field you select BUT I also need it to send an addition bit
of info in the form of $id so that on the processing page, I can extract
both the ID and the data entered from a single field. Obviously I can't use
a hidden field for this so the data has to be tacked-on to the input field
somehow?
Any help would save my life :-)
Chris
You mean like this:
In the display area of the script, using the ubiquitous while $myrow =
mysql_fetch_array($result), sub_key being the SUBscriber_KEY :
print( '<input type="checkbox" name=chkdelete[] value="' .
$myrow['sub_key'] . '">');
// rest of record - name, etc., then repeat
and as I was using this for a bulk delete, up top in the processing section:
//
// Bulk Delete
//
if ($chkdelete && $bulkdelete){
foreach ($chkdelete as $value){
$sql = "delete from subscriber where sub_key = '$value'";
$result = mysql_query($sql);
}
echo "<center><em>Selected Records deleted!</em><p>";
}
HTH -Miles Thompson
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php