OutOfInk Posted March 14, 2014 Share Posted March 14, 2014 In the database i need to extract the following information; Date, And return which round of game it is. Im sure their is a much better way and easier way than how im going about this, so if someone could improve the way im going about it would be awesome. There are 23 rounds. In each round there are 9 games. $round1 = mysql_fetch_row(mysql_query("SELECT MIN(Date) , MAX(Date) FROM `gamerounds` WHERE `round` = '1'")); $rounddate = date(); round one dates are from say 14th of March to 23rd of March, than round 2 will run from 27th of March to 1 of April if (($round1[0] >= $rounddate) && ($round1[1] <= $rounddate)){ echo "Round 1"; }else{ echo "Not round 1"; } I could do this for all 23 than compare them in a If and else code and eventually return what round it is but it would be like a page and im sure time wasting time and there has to be a better way Quote Link to comment https://forums.phpfreaks.com/topic/286958-fetching-data-from-mysql-with-php/ Share on other sites More sharing options...
jazzman1 Posted March 14, 2014 Share Posted March 14, 2014 Yes, there is a better way to achieve this. You could consider using mysql date/time functions and a sql between operator. Quote Link to comment https://forums.phpfreaks.com/topic/286958-fetching-data-from-mysql-with-php/#findComment-1472556 Share on other sites More sharing options...
OutOfInk Posted March 14, 2014 Author Share Posted March 14, 2014 Perfect; mysql_query("SELECT `Round` FROM `GameRound` WHERE `Date` BETWEEN `` AND ``"); But i still need to work out which dates it will go between Quote Link to comment https://forums.phpfreaks.com/topic/286958-fetching-data-from-mysql-with-php/#findComment-1472584 Share on other sites More sharing options...
ginerjm Posted March 14, 2014 Share Posted March 14, 2014 But i still need to work out which dates it will go between And that's why you are the programmer and we are the reviewers. Besides, I don't think many of us understand your scenario. Quote Link to comment https://forums.phpfreaks.com/topic/286958-fetching-data-from-mysql-with-php/#findComment-1472595 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.