OutOfInk Posted March 18, 2014 Share Posted March 18, 2014 I want to extract the MIN, MAX AND ROUND from the database. Can i get the result i want through making $count[][][] into a multiple array ? $rouCount = mysql_num_rows(mysql_query("SELECT MIN(Date) , MAX(Date) , `Round` FROM `GameRound`")); for ($i = 0; $i < $rouCount; $i++){ $count = mysql_fetch_row(mysql_query("SELECT MIN(Date) , MAX(Date) , `Round` FROM `GameRound`")); foreach ($count as $k => $lokk){ $a = $lokk; echo "Rounds $a[0] $a[1] $a[2]<br />"; } } Eventually I need it to display; Round 1 2014-03-14 2014-03-23 Round 2 2014-03-24 2014-03-29 Round 3 2014-04-14 2014-04-23 Round 4 2014-05-24 2014-05-29 atm i get; Rounds 2 0 1Rounds 2 0 1Rounds 1 Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 18, 2014 Share Posted March 18, 2014 without knowing what your input data is, it will be hard to help you based on your post above.. Quote Link to comment Share on other sites More sharing options...
OutOfInk Posted March 18, 2014 Author Share Posted March 18, 2014 Their isn't any input, or post data, its a function to work out what round it is from the db so i can compare it to the current date. Is that what you mean by input data? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 18, 2014 Share Posted March 18, 2014 the code you posted is operating on data from your database table. the input data to that block of code is the data that is stored in your database table. Quote Link to comment Share on other sites More sharing options...
OutOfInk Posted March 18, 2014 Author Share Posted March 18, 2014 (edited) 2 Western Bulldogs 0.00 North Melbourne 0.00 Etihad 2014-03-30 16:40:00 Open None None 3 1 GWS Giants 15 Sydney 1.00 Skoda 2014-03-15 16:40:00 Open None None Thats an example of the data input. Edited March 18, 2014 by OutOfInk Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 18, 2014 Share Posted March 18, 2014 the main reason i asked what your data is, that you expect to produce that output from, is because your posted query and code don't convey useful information. that query will only return one row, with the min of all dates, max of all dates, and the first encountered round number. you likely need a GROUP BY Round term in the query. your code is running that query once to get a count, then running that same exactly query again inside of a loop. your goal is to run one (or as few as possible) queries that gets the data you want in the order that you want it. there's no point in this. just run the query and loop over the row(s) it returns. your code that is iterating over the single row from that query is displaying three values, for the three things that query is selecting, min, max, and rounds. the output is "Rounds" followed by the first three characters of the minimum date found, "Rounds" followed by the first three characters of the maximum date found, then "Rounds" followed by the first three characters of the first encountered round number. i recommend you first study up on retrieving data from a query as this step in your code is nonsense. this is a case where rather than posting what you have tried (because it doesn't tell us anything useful), you need to post your data (enough of it to show anyone wanting to help what they would need to know to produce the specific output you expect from that data) and post the excepted output (which we already know.) if the data you are posting doesn't clearly correspond to the output you have shown from that data, don't bother posting it as it won't help anyone to help you. Quote Link to comment 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.