note 11585 added to Variable variables

From: Date: Mon, 26 Feb 2001 14:11:40 +0000
Subject: note 11585 added to Variable variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-11605@lists.php.net to get a copy of this message
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 I used it for an intranet I'm building in my company and this is working great ! http://www.php.net/manual/en/language.variables.variable.php

« previous php.notes (#11605) next »