i wanna use an update query on my database to update a field depending on 2 others but requires a php function to be called to calculate the value of the 2 fields.

like i have

UPDATE person SET tax = 'Yes' WHERE "php function here" > 12000

"php function here" is a function i have in a php script that gets called with 2 parameters like get_income(pay, time)
something like that that calculates a figure depending on the 2 other fields in the database and returns the result and if that is greater than a certain figure it updates that record. i cannot workout how to incorporate the php function into the update query to get it to work. the 2 parameters in the function are fields in the database that i want to pass to that function.
in microsoft access its easy but i cant do it in php for some reason.

    the 2 parameters in the function are fields in the database that i want to pass to that function

    This part won't work in the way you hope. Unlike M$ Access, you're working in 2 environments: PHP and MySQL. You can't simultaneously select, manipulate, and update data in the 2 environments.

    In all probability, however, you can use your UPDATE SQL code to manipulate the database data, and thereby achieve the same result.

      i'll have a play but i dont think it will work as good as i hope.

        Can you just stick the result of your function in a variable and put that variable in the query?

          Originally posted by klatt
          Can you just stick the result of your function in a variable and put that variable in the query?

          gotta grab the 2 variables from each row of the database first, think the only way i can do it is loop all the records that i need and query each one that way then stick it into a variable then back into the database if something needs to be done.

            Write a Reply...