Jump to content

mkosmosports

Members
  • Posts

    196
  • Joined

  • Last visited

    Never

Everything posted by mkosmosports

  1. jesirose just came in. I could definetely use her brains on this one....
  2. Im thinking I need to use a for loop rather than foreach...ahh...this is killin me....
  3. Hey, I know there are tutorials here, but what Ive found only covers pagination using mysql queries. Im trying to split the results of an array only, over multiple pages...
  4. bump..bump... , just in case anyone has heard of a successfull to do what Im trying to do...
  5. Alright, Ive gotten this far: if(isset($_GET['page'])) //If there is a page available { $pageNum = $_GET['page']; } $trcount=0; //Number of loop results variable foreach($trarray as $value) //This is the loop on the main array { $pid = $value['id']; if(isset($_GET['l']) && $_GET['l'] == "2") { $date = substr("{$value['date']}",0,4); $datemon = substr("{$value['date']}",4); $shmon = $_SESSION['months'][$datemon][0]; } else { $date = $value['date']; $shmon = $_SESSION['months'][$date][0]; } $pos = $value['pos']; $nickname = $value['nickname']; $toteam = $value['toteam']; $fromteam = $value['fromteam']; $status = $value['status']; $sum = $value['sum']; if ($date == $mon) //Only looking to retrieve info from a specific month { $trcount++; //Counting number of loop results if (intval($sum) && $sum > "5000000") { echo("<tr style=\"background-color: #F5AA19; font-size: 10px\"><td align=\"center\">$shmon</td><td align=\"center\">$pos</td><td><a href=\"mainstats.html?l=3&player=$pid\"><b>$nickname</b></a></td><td>$fromteam</td><td style=\"font-weight: bold\">$toteam</td><td>$status</td><td><b>$sum</b></td></tr>"); } else { echo("<tr style=\"font-size: 10px\"><td align=\"center\">$shmon</td><td align=\"center\">$pos</td><td><a href=\"mainstats.html?l=3&player=$pid\"><b>$nickname</b></a></td><td>$fromteam</td><td style=\"font-weight: bold\">$toteam</td><td>$status</td><td>$sum</td></tr>"); } } } $maxpage = ceil($trcount/70); //See how many pages are needed based on number of results returned by array $self = $_SERVER['PHP_SELF']; echo("</table>"); if($trcount >= 70) //Only show the page links if there are more than 70 array results { echo("<div style=\"margin: 10px 0px; text-align: center\">"); for($page = 1; $page <= $maxpage; $page++) { echo("<a class=\"trmonsel\" href=\"$self?type=transfers&mon=$mon&page=$page\">page: $page</a>"); } } echo("</div></div>");
  6. Hey, Can anyone help me out regarding the easiest way of displaying foreach array results over multiple pages? Ive seen a tutorial about how to do it for an mysql query but I cant seem to get it together with an array. Any help appreciated.. Thanks..
  7. Hello, Anyone know of a simple script that would time how long it took for the entire page to load? Thanks.
  8. Hey, Ive tried this before, however it puts everything in another array, and this produces unexpected results later on.....
  9. Hey, Ive got the following loop which loads a whole bunch of data from a query into an array. while ( $row = mysql_fetch_array($alltransfers, MYSQL_ASSOC) ) { $alltrarr[] = array('id' => $row["ID"], 'date' => $row["DATE_FORMAT(TP.START_DATE,'%m')"], 'pos' => $row["CODE"], 'nickname' => $row["NICK_NAME"], 'fullname' => $row["FULL_NAME"], 'toteam' => $row["QUICK_NAMEto"], 'fromteam' => $row["QUICK_NAMEfrom"], 'status' => $row["STATE"], 'sum' => $row["TRANSFER_SUM"]); } Then, I load that array into the session. $_SESSION['trdata'] = $alltrarr; Is there a way I can have the loop load the query data directly into the session array, so I dont have to essentially create two arrays, like in the above case "$alltrarr" and $_SESSION['trdata']? Thanks
  10. Yeah, that works. Thanks Ted Chou. I did have to enable URL file-access in the server configuration. After reading up on php.net, turns out php doesnt handle including files from other directories very well. A user posted this question there: "Why are the included files not looked up relative from the file that includes them and then in the include path? This would be a behavior like in all other languages."
  11. Well, dbconnect.php is in the root folder of the site. I then have another file in rootfolder/maincontent that needs to include dbconnect.php.
  12. I want to use the include function on a file thats in the top-level directory of my site. I call on that from many sub-level directories, so whats the syntax to always call on that file, which is in the top-level directory? Ive tried: include ("../dbconnect.php");, include ("/dbconnect.php"); Doesnt work...
  13. I see what you mean. You know what, I gotta think this over. I might not need what I think I need. What I need is some heavy php learning... :P
  14. Sure. This is a soccer news/stats website. The queries ran are queries that retrieve stats. numbers, names, etc. Ive redone the code so that most queries put its results into arrays. The purpose of that is so there are less queries being ran, and if there are no new relevant entries, just use whats in the existing array (So Im hoping the array can exist until the user has finished the session maybe? How long does an array stay in memory anyways?) Here is an example query that retrieves teams playing in a specific league. $result3 = @mysql_query("SELECT GT.START_DATE as sdate, GT.END_DATE as edate, T.ID as teamid, T.QUICK_NAME as quickname, T.OFFICIAL_NAME as fullname, T.COUNTRY as country FROM sf_group_team GT, sf_team T WHERE GT.START_DATE BETWEEN '$seasonbeg-06-20' AND '$view-03-10' AND GT.GROUP_ID = $group AND GT.TEAM_ID = T.ID"); if (!$result3 ) { echo("<p>Error performing query: " . mysql_error() . "</p>"); exit(); } Heres the array which will contain the necessary results. while ( $row = mysql_fetch_array($result3, MYSQL_ASSOC) ) { $result3arr[] = array('quickname' => $row['quickname'], 'teamid' => $row['teamid'], 'country' => $row['country'], 'sdate' => $row['sdate'],'edate' => $row['edate']); } Now I only want the query to run again only if there are new PK entries in that table. (Id have to write another query to check that, mysql_query would do, but maybe there is a specific mysql function for that in php.) If there are no new PK entries in that table I want the array to be used to show the necessary data. Does that help businessman? Thanks.
  15. What do you mean "download what the user has searched"? Can you provide an example of this?
  16. Hey all, Ive recently restructured some of my code, so that query results get put into multidimensional arrays and then displayed using loops. Now what Id like to do is set these queries to run only when there are new entries present in the table. Im thinking I should learn about using sessions and then have each query run once per session, then always run a small query checking for a new PK, and then run the main query only if there is another a new PK present in the table. Is this a correct way of thinking? Has anyone else successfully implemented similar script before? All ideas, suggestions, insults welcome..... ;D mkosmosports
  17. Ahhh..I got it folks, nevermind my last post. The solution is: foreach ($arr as $value => $k) { foreach ($k as $key) { if ($key == "Glenn") { echo "$value;<br />\n"; } } } This has given me all the last names when first name is Glenn..
  18. Damnit, I still cant get a certain syntax right. The following md array: Array (     [Griffin] => Array         (             [0] => Peter             [1] => Lois             [2] => Megan             [3] => Glenn         )     [Quagmire] => Array         (             [0] => Glenn         )     [Brown] => Array         (             [0] => Cleveland             [1] => Loretta             [2] => Junior         ) ) How can I get all the last names(1st level array id's) when the first name (2nd level array) is Glenn? Thanks!
  19. Thanks Jesirose! That loop does it. The query I had was ordered already so I didnt need to make use of ksort. Another array question for y'all. Can I merge/combine two arrays together (ok, I know I can use array_merge, but....), WHILE throwing out any duplicates so I come out with an array only containing all unique values in the other two arrays combined... Thanks...
  20. Yeah, thats the problem though, the ids of each 1st level array are not numeric, so sorting them will not make 0 the first id. They are dates, like 200701, 200611, etc. Array (     [200701] => Array         (             [1] => France         )     [200611] => Array         (             [1] => Italy             [2] => England         )     [200610] => Array         (             [1] => England         ) ) So now what I want to do is somehow pull the 200701 out of this md array, and use it in a variable later on.
  21. Damn, I hate being persistent and annoying but is this really impossible?? I mean, there is gotta be a way to somehow retrieve the highest value of the ID in an associative array and then being able to use it... I promise Ill help people out when I gain enough knowledge... :P
  22. hmmm....I guess this is impossible....ok, Ill have to rearrange some things then... Thanks!
  23. :P. Let me rephrase that question. Is there a way to use the max function on the value of the ID in a associative array where that value is a certain number?
  24. Ive got this multidimensional array: Array (     [200701] => Array         (             [0] => France             [1] => Serbia         )     [200611] => Array         (             [0] => Italy             [1] => Italy             [2] => England             [3] => England         )     [200610] => Array         (             [0] => England             [1] => England         ) ) Im interested in doing three things with it: 1. Get the Max year/month value, so 200701. 2. Clean up the array to avoid duplicates in the subarray. Any ideas? Many thanks!
×
×
  • 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.