rgb192
asked on
variable variables for tablename
want to make the mysql table dynamic
$used_table='search';
change
$search_id=$rowcheck->sear ch_id;
to
$${$used_table.'_id')}=$ro wcheck->$u sed_table. '_id';
$used_table='search';
change
$search_id=$rowcheck->sear
to
$${$used_table.'_id')}=$ro
Do this:
$used_table = "search";
$used_table_id = $used_table."_id";
$$used_table_id = $rowcheck->$used_table_id;
That will create the same result as:
$search_id = $rowcheck->search_id;
You might also consider using the extract() function.
$used_table = "search";
$used_table_id = $used_table."_id";
$$used_table_id = $rowcheck->$used_table_id;
That will create the same result as:
$search_id = $rowcheck->search_id;
You might also consider using the extract() function.
Please show us the $rowcheck object. I smell something fishy in this design pattern and I think if we knew a little more about what you're working toward we could suggest a design pattern that would be more secure and less brittle than what I sense may be going on here.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, I should use another design pattern.
But this example works the best
Thanks
But this example works the best
Thanks
$i = "_id";
$used_table[$i] = $rowcheck->$used_table[$i]