Jump to content

How to loop until a certain value is met.


Phpfr3ak

Recommended Posts

Do you mean you want a script that just sits there and waits until a particular db column gets changed?

 

Essentially you'd just make a while(true) loop and inside it query that column and when it changes do something.

 

Not very efficient though.  Perhaps you could explain your situation / goal?

Link to comment
Share on other sites

Sorry basically its something along the lines of, Player A buys x amount from player B, the cron runs every :10 on the hour, and essentially sells that resource, resourses have different values, for example at :10 player A sells 100 resourses, 50 of those resources would be in 1 row, and 50 in another, if that makes sense it can vary, hope that explains it somewhat better?

Link to comment
Share on other sites

I'm not sure if this is what you were asking for, but I think it will point you in the right direction at least. I am also incredibly new to PHP so I doubt this code is optimal.

 

<?php
$query =
// the query you want to execute once said number is met
$check_query =;
// query used to check current number
$resource_number = mysql_query($check_query);
$resource_goal_number =;
//number to execute query on
$resource_execute = mysql_query($query);

while $resource_number < $resource_goal_number {
 $execute = false;
 if ($execute) {
	 mysql_query($query);
	}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.