i am a little lost on what you are trying to achieve so i will just post a basic sample of what i think you might need.
Create function and have variables to pass into the function that can be interchanged
Code: Select all
function updaterows($var1, $var2, $var3,$var4,$var5,$var6,$var7,$session_username,$gender)
{
$updateenclosure="UPDATE `$var1` SET `$var2`=`var2`+`$var3`' WHERE `var4`='$session_username' AND 'var5' < 3 AND `var6` < 100 AND `var7` > 49 AND gender = 'female'";
mysql_query($updateenclosure) or die("Could not update royal length");
}
then depending on how you wanna loop and what you are trying to do you can call the function within the loop
Code: Select all
for($i=0;$i<3;$i++)
{
if ($i == 0)
{
updaterows('royal', 'hunger', 'length',$i,$stage,$whatever,$lifestage,$session_username,$gender)
{
if ($i == 1)
{
updaterows('notroyal', 'thirst', 'butt',$i,$guesswhat,$somethingelse,$lifestage,$session_username,$gender)
{
if ($i == 2)
{
updaterows('pesant', 'tigers'', 'bears',$lions,$stage,$whatever,$lifestage,$session_username,$gender)
{
}
ect... ect...