Jump to content

PHP run query


tebrown

Recommended Posts

Hey Guys,

 

I have setup a mysql query that is run everytime the page is refreshed. Its on my page called secure.php, which is on everypage within my website.

 

At the moment it finds all the fixtures in the database and checks if the current time has passed its specific time. It all works fine but im wanting to get that specific fixture_id so that i can then send a notification to the manager saying that the current time has passed ur fixture time.

 

$fixture = ("SELECT * FROM `fixtures`") or die(mysql_error());
$resultfixture=mysql_query($fixture);

if (mysql_num_rows($resultfixture) != 0) {
while($rows = mysql_fetch_array($resultfixture)) {

	mysql_query("UPDATE `fixtures` SET `status` = '2', `result`='TBA' WHERE UNIX_TIMESTAMP() > `time` AND `status`='1'") or die(mysql_error());  
}

}

 

Any help much appreciated!

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/268531-php-run-query/
Share on other sites

The code you posted reads every row in the table, then for every row in that table if performs the same update. You only need to perform the update once.

 

You mention "that fixture" but give no details on what that means. What are you trying to do?

Link to comment
https://forums.phpfreaks.com/topic/268531-php-run-query/#findComment-1379139
Share on other sites

Ok so lets say that msyql query runs and it finds 1 fixture that has passed its fixture time, i want to be able to get the id of that fixture so i can then run a another mysql_query that will notify the manager to let him know the current time has passed the fixture time.

 

Hope that makes sense.

Link to comment
https://forums.phpfreaks.com/topic/268531-php-run-query/#findComment-1379141
Share on other sites

I need to update all fixtures where the current time has passed the fixture time. The query will then update the column 'status' to '2'.

 

I then need to GET the fixtures that it just updated so i can run another query that will notify the managers of those fixtures.

 

 

Link to comment
https://forums.phpfreaks.com/topic/268531-php-run-query/#findComment-1379146
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.