note 11585 deleted from language.variables.variable by cmb

From: Date: Sun, 12 Jan 2020 08:30:42 +0000
Subject: note 11585 deleted from language.variables.variable by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213860@lists.php.net to get a copy of this message
Note Submitter: bpotier at edreamers dot org ---- A good example of the use of variable variables name. Imagine that you want to modify at the same time a list of more than one record from a db table. 1) You can easily create a dynamic form using PHP. Name your form elements using a static name and the record id ex: <input name="aninput<?php echo $recordid?>" which gives in the output something like <input name="aninput15"> 2)You need to provide to your form action/submit script the list of records ids via an array serialized and urlencoded via an hidden field (to decode and un serialize once in the submit script) 3) In the script used to submit you form you can access the input value by using the variable ${'aninput'.$recordid} to dynamically create as many UPDATE query as you need [Editor Note: Simply use an array instead, for example: <input name="aninput[<?php echo $recordid?>]" And loop through that array. -Philip]

« previous php.notes (#213860) next »