Forum Moderators: coopster
i work on a site where the contents can grow, so i wanted to have the possibility to have the admin add 'groups'.
The client must have the option to fill in a code in any of these groups.
i want something like below, but i can not get it to work?!
-----------a include file------------
if ($actie=="formlist") {
while($record = mysql_fetch_object($sql)){
echo "<tr><td align=\"right\"><b>$record->game #id</b></td><td> <input type=\"txt\" name=\"$record->game\" value=\"0\" size=\"12\" $readonly ></td></tr>" ;
} }
if ($actie=="postlist") {
while($record = mysql_fetch_object($sql)){
$$record->game=$_POST['$record->game'] ; echo $_POST['$record->game'] ;
} }
if ($actie=="showpost") {
while($record = mysql_fetch_object($sql)){
echo "<tr><td>" . $record->game . "</td><td>" . $_POST['$$record->game'] . "</td></tr>" ;
} }
--------------end---------
the double $$ is not a typo, i wanted to assign the variable the sql-field-content as a name
i feel like i dont see the obvious sollution, and it has taken me many many hours now.
help :(
I'm not exactly sure what is wrong with your code, but MAYBE this will help. Change
$$record->game=$_POST['$record->game'] ;
to something like this:
${$record->game}=$_POST['$record->game'] ;
See if this makes a difference. Good luck!
eelix
${$record->game}=$_POST["$record->game"];
The single quotes ensure that what's inside them is used as a literal string instead of being parsed. I am pretty sure it would also work if you don't use quotes (since you are calling a variable anyways):
${$record->game}=$_POST[$record->game];
You say
i can not get it to work
I also notice you use the deprecated
if ($actie=="formlist") { If after this, you still can't find the problem, try to be a bit more specific about what does and what doesn't work. Cuz i'm sure there's a solution to whatever your problem is