Re: Re: Variable name as a string

From: Date: Wed, 27 Aug 2008 15:55:11 +0000
Subject: Re: Re: Variable name as a string
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-278782@lists.php.net to get a copy of this message
Perhaps this example may help. Eg: a form with checkboxes and submit button, a few are checked and I want to delete the corresponding records from the database. The database table has an ID column: for each ($argv as $key=>$value) { //$key is named cb_1 $value is "checked" //to get 1 from the key name, then //needed: function like nameof() $var=nameof($key); $ID=substr($var,3); $query="delete * from dbtable where ID='$ID'"; //etc }
For database use I do the following in forms: name="data[field_name]" Or for multiple table that you update together: name="data[table_name][field_name]" -Shawn


« previous php.general (#278782) next »