Jump to content

mkosmosports

Members
  • Posts

    196
  • Joined

  • Last visited

    Never

Everything posted by mkosmosports

  1. True artacus, my initial post is a little confusing. Ive narrowed it down to this though. How can I take distinct values from two columns together instead of each column separately. I mean so: SELECT DISTINCT TEAM_ID, OLDCLUB_ID from sf_team_player This will get me distinct values from TEAM_ID and OLDCLUB_ID separately . The thing is I want distinct values from both of these columns at once. Is that clearer? Any ideas? Thanks.
  2. Hey everyone, Ive got this query: SELECT DISTINCT DATE_FORMAT(START_DATE,'%Y%m') AS date, TEAM_ID as tid,  OLDCLUB_ID as tid2 from sf_team_player WHERE OLDCLUB_ID IS NOT NULL ORDER BY START_DATE DESC TEAM_ID as tid,  OLDCLUB_ID as tid2. I want to combine these two selections so they produce only one resultset. So basically select tid and tid2 would produce one resultset of those two without any duplicates. Any ideas? Thanks.
  3. Ok, fair enough. That makes sense. Thanks Jenk and Jesirose!
  4. Damn, looks like I confused you guys a little....:P...my apologies... echo("<div class=\"teamlistcupcontainer\">");     foreach($result3arr as $value)     {     $tname = $value['quickname']; $tallowed = $value['linkable'];     $tid = $value['teamid'];     $sdate = $value['sdate'];     if($sdate > "$seasonbeg-07-21" && $sdate < "$seasonbeg-08-01")     {     echo("<div class=\"teamlist\"><a href=\"mainstats.html?l=2&team=$tid\" alt=\"\">$tname</a></div>");     } echo("</div>"); The above loop contains an if condition and the results of it are inside div class teamlistcupcontainer. I have 3 more conditions to write for this loop, and I need them to also be inside div class teamlistcupcontainer. Logically, I would need to write 3 more foreach loops, but Im asking if this is something I can avoid this somehow....
  5. :)..I know it doesnt "need" to stay inside the loop, but Id like it too. Id just want to put the echos in the condition in div tags that only appear once. What Im trying to avoid is writing multiple foreach loops. I wanna write just one... I guess its impossible though. I was thinking there might be some kind of array function....
  6. The thing is though, it needs to stay inside the foreach loop. Except I want it to only run once...
  7. Hey, I have this loop:     foreach($result3arr as $value)     {     $tname = $value['quickname'];     $tid = $value['teamid'];     $sdate = $value['sdate'];     if($sdate > "$seasonbeg-07-01" && $sdate < "$seasonbeg-07-20")     {     echo("<div class=\"teamlist\"><a href=\"mainstats.html?l=2&team=$tid\" alt=\"\">$tname</a></div>");     }     else if($sdate > "$seasonbeg-09-01" && $sdate < "$seasonbeg-09-20")     {     echo("<div class=\"teamlist\"><a href=\"mainstats.html?l=2&team=$tid\" alt=\"\">$tname</a></div>");     }     } What I would want to do is put the echos inside the condition in certain html tags, but those tages should only appear once per condition, so something like                         echo("<div>"); <---this needs to run only once though     if($sdate > "$seasonbeg-07-01" && $sdate < "$seasonbeg-07-20")     {     echo("<div class=\"teamlist\"><a href=\"mainstats.html?l=2&team=$tid\" alt=\"\">$tname</a></div>");     }                         echo("</div>"); <---this needs to run only once though Is this even possible? Any help appreciated!
  8. Beautiful. Not only is that what Im looking for, I fully understand whats going on. Initially, I think I was thinking a little too hard about it.. :P Thanks guys!
  9. Still not getting the clear picture. Array (     [Arsenal] => Array         (             [teamid] => 1             [fullname] => Arsenal London             [linkable] => y             [sdate] => 05             [edate] =>         )     [Aston Villa] => Array         (             [teamid] => 2             [fullname] => Aston Villa             [linkable] => y             [sdate] => 05             [edate] =>         ) ) Out of this md array. How can I loop through and pull out the the second level id (ex. Aston Villa) where [sdate] = 05 for example. I just cant seem to get it right.. Any help appreciated. Marek
  10. How can I write a condition, if $variable is a digit? I have numbers and words in a table. Is there any simple way to write that condition? Thanks.
  11. Hmm. Maybe I should start off a little easier.. ;D How can I parse through all second-level arrays and retrieve all of the values from there. I guess if I ran loops through all of them that could do it, but are there any quicker ways? Thanks.
  12. Perfect! That works for retrieving the max number across all subarrays anatek. Nnnnow though, I have a brain teasing question I just cant seem to answer by myself. I think Ive jumped into working with arrays at a level a little too advanced to me, so I seek your help..... This md array: Array ( [3] => Array (   [0] => 200701   [1] => 200609   [2] => 200608   [3] => 200607   [4] => 200606   [5] => 200605   [6] => 200603   [7] => 200601   [8] => 200512   [9] => 200508 ) [1] => Array (     [0] => 200611     [1] => 200610     [2] => 200609     [3] => 200608     [4] => 200607     [5] => 200606     [6] => 200605     [7] => 200602     [8] => 200601     [9] => 200509     [10] => 200508 ) ) What I want to do with it is get all distinct years from a given subarray, and all of of the months available for those years. So for subarray[3] I want to retrieve 2005(12,08), 2006(09,08,07,06,05,03,01), 2007(01). I also want to do this regardless of what the subarray associative id is. The reason for this is, on another page I want to run a loop generating the months available if year is a certain value. Also, I want a loop generating links to the remaining available years, with the maximum month available in that year. Anyway, I hope I didnt confuse y'all too much. Is this even possible? I want to do this to avoid running more sql queries than I need to, is it worth it? Any idea welcome! Thanks.
  13. I have this array called $data. Array (     [3] => Array         (             [0] => 200701             [1] => 200609             [2] => 200608             [3] => 200607             [4] => 200606             [5] => 200605             [6] => 200603             [7] => 200601             [8] => 200512             [9] => 200508         )     [1] => Array         (             [0] => 200611             [1] => 200610             [2] => 200609             [3] => 200608             [4] => 200607             [5] => 200606             [6] => 200605             [7] => 200602             [8] => 200601             [9] => 200509             [10] => 200508         ) ) Now, if I go echo(max($date[1]) that will bring me out the maximum number where the subarray is 1. How can I get the maximum number regardless of the subarray though. So just in general? Thanks in advance.
  14. I have a mysql table that consists of the following columns: START_DATE, TEAM_ID. What I want to do is run a query that retrieves distinct START_DATE values and then all of the distinct TEAM_ID values that are in the same result row as the distinct START_DATE values. In case Im being a little confusing, in mysql I have: |START_DATE|TEAM_ID| |200608|6| |200608|6| |200608|7| |200608|7| |200609|4| |200609|4| What Id like to do then is retrieve the unique dates, and the unique teamids for that date, so something like:|200608 => 6,7|200609 => 4| This is what I have so far: $test3 = @mysql_query("SELECT DISTINCT DATE_FORMAT(START_DATE,'%Y%m') AS date, TEAM_ID AS teamid from sf_team_player WHERE OLDCLUB_ID IS NOT NULL ORDER BY START_DATE DESC"); $rows = mysql_num_rows($test3); for($i=0;$i<$rows;$i++) { $tid = mysql_result($test3,$i,'teamid'); $date = mysql_result($test3,$i,'date'); $testarr[$date] = $tid; } The above returns an array telling me the number of teamids (theyre not unique though, which is part of the problem) that exist whenever the START_DATE is $date. Now how can I bring that teamid number down by ignoring duplicates (Im having trouble adjusting my query for that, Im pretty sure that is where the problem is) and creating a multidimensional query that will not only tell me the number of unique teamids whenever START_DATE is $date but also show them to me? Help much appreciated... mkosmosports Hmm...was my post removed? I swear I had posted it and then it was no longer there when I refreshed. If Im breaking the rules, can someone tell me how Im breaking the rules and then remove it. Thanks!
  15. I have a mysql table that consists of the following columns: START_DATE, TEAM_ID. What I want to do is run a query that retrieves distinct START_DATE values and then all of the distinct TEAM_ID values that are in the same result row as the distinct START_DATE values. In case Im being a little confusing, in mysql I have: |START_DATE|TEAM_ID| |200608|6| |200608|6| |200608|7| |200608|7| |200609|4| |200609|4| What Id like to do then is retrieve the unique dates, and the unique teamids for that date, so something like:|200608 => 6,7|200609 => 4| This is what I have so far: $test3 = @mysql_query("SELECT DISTINCT DATE_FORMAT(START_DATE,'%Y%m') AS date, TEAM_ID AS teamid from sf_team_player WHERE OLDCLUB_ID IS NOT NULL ORDER BY START_DATE DESC"); $rows = mysql_num_rows($test3); for($i=0;$i<$rows;$i++) { $tid = mysql_result($test3,$i,'teamid'); $date = mysql_result($test3,$i,'date'); $testarr[$date] = $tid; } The above returns an array telling me the number of teamids (theyre not unique though, which is part of the problem) that exist whenever the START_DATE is $date. Now how can I bring that teamid number down by ignoring duplicates (Im having trouble adjusting my query for that, Im pretty sure that is where the problem is) and creating a multidimensional query that will not only tell me the number of unique teamids whenever START_DATE is $date but also show them to me? Help much appreciated... mkosmosports
  16. You can use AJAX to have just specific div (or other) elements to load without the entire page loading. Check this out bonrouge.com...
  17. That makes sense, using a loop. For some reason I thought since a complete array is in memory, I wouldnt need a loop to retrieve values. Ah, it sucks being a beginner! Thanks bro!
  18. Hey I have a multidimensional array. Array ( [0] => Array ( [dt] => 200701 [tid] => 46 [gid] => 3 ) [1] => Array ( [dt] => 200611 [tid] => 19 [gid] => 1 ) [2] => Array ( [dt] => 200611 [tid] => 79 [gid] => 5 ) [3] => Array ( [dt] => 200610 [tid] => 20 [gid] => 1 ) [4] => Array ( [dt] => 200609 [tid] => 14 [gid] => 1 ) [5] => Array ( [dt] => 200609 [tid] => 253 [gid] => 1 ) [6] => Array ( [dt] => 200609 [tid] => 46 [gid] => 3 ) [7] => Array ( [dt] => 200609 [tid] => 20 [gid] => 1 ) [8] => Array ( [dt] => 200609 [tid] => 16 [gid] => 1 ) [9] => Array ( [dt] => 200609 [tid] => 21 [gid] => 2 ) [10] => Array ( [dt] => 200609 [tid] => 62 [gid] => 5 ) How can I retrieve [tid] and [gid] values based on what the [dt] value is? Ie. I want to find out what [tid] and [gid] is if [dt] = 200609..... This must be a simple thing , Im just not understanding the structure of the multidimensional array.... Thanks for your help!
  19. Thanks scotmcc and Jesirose for your help! Im gonna use that and put together what I want to achieve. Hopefully it'll work. Ill let ya'll know....
  20. Is there a way I can manually assign ID keys in a multidimensional array?
  21. I have a multidimensional array.. $monthss = array("2digit"=>array("01","02","03","04","05","06","07","08","09","10","11","12",), "shorttxt"=>array("Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"), "longtxt"=>array("January","February","March","April","May","June","July","August","September","October","November","December")); Then I run a loop and I want to take out values from that array and place them as a variable. Ive got: $var = $monthss[$2digit($trmon)]; as well as several other varieties... Obviously this is not the way to use the md array.... :P Any help appreciated.. Thanks.
  22. Thanks fellas! That makes sense. I gotta start figuring those out...
  23. I want php to run and make a quick check to see if an id exists in mysql. This id features as a url parameter. Currently I do by running a query and selecting all of the id's, putting them into an array and running a condition that if the id in the url isnt in that array show an error page. Is there a quicker way of doing this, perhaps without a mysql_query, but using some other mysql function? Thanks!
  24. Bumping it up in case obsidian pops up again. Obsidian, youre not gonna leave me hanging at the last hurdle.... :D
  25. Yeah, some more code would be helpful. Where is $tablename derived from?
×
×
  • 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.