View Single Post
Old Nov 20th, 2007, 6:58 AM   #6
davil
Newbie
 
Join Date: Nov 2007
Posts: 27
Rep Power: 0 davil is on a distinguished road
Re: Question regarding data input into PHP/Mysql using something other than GET

Ok so I'm getting into this and it seems to be working fine but I'm having problems with the foreach command...

When I get the info from a MySQL database I usually use the following command to assign a variable to each value:

php Syntax (Toggle Plain Text)
  1. foreach ($row as $key => $value) {$$key = $value;}
This works perfectly but I was wondering is there a way to check something like $datestamp vs $new_datestamp by doing this?

php Syntax (Toggle Plain Text)
  1. foreach ($row as $key => $value) {
  2. $$key = $value;
  3. if ($new_$$key==$$key){echo "$new_$$key is same as old $$key, which is $value\n";
  4. }
I know this doesn't work above but I'm presuming it's something to do with my syntax... I've had a look at PHP.net tutorials and done a bit of googling but I'm lost on this simplest of all problems...

I could do it the long way with like 20 conditions but I want to get more efficient in my programming.
davil is offline   Reply With Quote