Jump to content

Jim R

  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by Jim R

  1. Oh...one thing... Not everyone will have a County entry. There is a level of registration that is for college coaches. I didn't think about that, until I saw the results. Otherwise it cleaned up my NULL entries. EDIT: So I made the sub_region a LEFT JOIN, and it worked.
  2. The use of meta_key for the sub level is because there are a couple of other rows with s2member entries for each User. There is just one row for each User with the county data. The county data is actually a custom entry I put in the User registration form. I did start using JOIN first, but I didn't remember (or think of) using aliases. I'll give this a try...thank you.
  3. If you're familiar with WordPress, each user_id produces about 15-20 rows of usermeta data. I just want to get a couple of them, but the two rows for a User have serialized data. I'm looking to producing a list of Users who subscribe to a certain level -- sub_level -- and which part of Indiana they're from -- sub_region: North(1), Central(2) or South(3). Truly just interested in the s2member_ value in sub_level and the # (1,2 or 3) in sub_region, so there is likely a better way to get just that than LIKE, but I can code it how I want in the PHP output. I'm wanting only the rows of Users where sub_level isn't NULL. select u.id, u.user_login, u.user_email, u.user_registered, (select um1.meta_value from wp_usermeta um1 where u.id = um1.user_id and um1.meta_value LIKE concat ('%', 's2member_', '%') and um1.meta_key = 'wp_capabilities') as sub_level, (select meta_value from wp_usermeta um2 where u.id = um2.user_id and um2.meta_value LIKE concat ('%', 'county', '%')) as sub_region from wp_users u Table structures: wp_usermeta: wp_users: Output looks like this: I tried 'WHERE sub_level is not null', but as you know, can't use an alias in a WHERE. I tried 'WHERE um1.meta_value is not null' in the subquery, but that didn't change the results. I also tried it in the outer query, but I got an unknown column error..
  4. After I got most of the descriptors to lineup, it only pulled one row. It should've pulled two for now. Ultimately, it will pull in however many set up on each date we post. Also, the problem on the grade is their grade has to remain relative to the date of the game. Ultimately, I'll be adding variables to the query, referencing the date of the games. I'd think I can remedy this with a CASE statement.
  5. Thanks...I'll play around with it. I still can't wrap my head around subqueries -- when to use them, where to use them, how to use them. Disappointed I was that far off.
  6. The root of my issue, how to break up the hplayers and aplayers strings so I can print the player lists how I'd like them? I guess the side question goes toward what you said earlier, how creating separate tables for position and grade change what's in the hplayers and aplayers fields?
  7. Added this: $results = mysqli_query($con,$query); while($line = mysqli_fetch_assoc($results)) { $lines = explode(PHP_EOL,$line['hplayers']); $array = array(); foreach ($lines as $player) { $array[] = str_getcsv($player); } print_r($array); Producing this: I tried echoing $array[0], but it just produced 'array'.
  8. Ultimately, it seems, the results would still end up in hplayers or aplayers. How would I otherwise get those two columns linked to each player?
  9. With commas coded in: Logan Imes,6,4,1,23;Nick Richart,6,8,5,23;Isaiah Davis,6,8,5,22;Edward Thomas,6,4,2,23 I could concatenate the whole thing, but it would still be, Logan Imes, 6'4", 1, 23. How then to get the 1 = point guard and the 23 = JR.
  10. Yes, ultimately grade > '21' will be grade > $season. I'm trying to get the desired results for right this moment. I'm just struggling with turning the data in the field... ...into something more palatable onscreen. Would coding commas into the Concat help?
  11. I could for position, as they could never change, but normally I use this: $position = array ( '1' =>'Point Guard', '2' =>'Shooting Guard', '3' =>'Small Forward', '4' =>'Power Forward', '5' =>'Center' ); The grades change each year relative to class, and I have a Seasons table that I call to in each function I need it, taking the date of the post, then I use CASE to determine the grade. The problem I see is separating the values in the output. Adding separators would allow me it explode it. Could I then use it that way? The only other times I've exploded a list is when it just came from one column.
  12. ...or if there is a better way to get the data. Creating game capsules for basketball games. They are essentially previews of upcoming games. They will include the team name and 'key' players. I'm just now getting to the output, and I feel like my query is getting me the information I need from it. School names, player names, player height (feet, inches), position he plays and what grade he is in. I could just CONCAT that all out, but I really want to convert the numerical values for position and grade into words rather than numbers. Position: 1 = point guard, 2 = shooting guard, etc Grade: 22 = senior, 23 = junior, etc Normally, I know how to do that when I'm pulling non-array data, even when it's an array. I'm not sure, however, if I'm creating an array. $query="SELECT h.school as home, a.school as away, preview, group_concat( distinct CONCAT(hp.nameFirst,' ',hp.nameLast),hp.feet,hp.inches,hp.position,hp.grade SEPARATOR ';' ) as hplayers, group_concat( distinct CONCAT(ap.nameFirst,' ',ap.nameLast),ap.feet,ap.inches,ap.position,ap.grade SEPARATOR ';' ) as aplayers FROM a_schedule sc LEFT JOIN a_schools h on sc.home_id = h.id LEFT JOIN a_schools a on sc.away_id = a.id LEFT JOIN a_players hp on h.id = hp.schoolID and hp.grade >'21' and hp.key='1' LEFT JOIN a_players ap on a.id = ap.schoolID and ap.grade >'21' and ap.key='1' Group by sc.id order by sc.id "; $results = mysqli_query($con,$query); while($line = mysqli_fetch_assoc($results)) { echo $line['hplayers']; } This is what the output looks like in my query: Ultimately, it will read on screen: Dayveon Turner, 6'0" point guard; SR Reggie Bass, 6'4" shooting guard; SR Antonio Lisenbee, 6'6" power forward; SR Do I fetch array? Table structures: a_schools a_schedule a_players (id column too)
  13. In my database, I have multiple entries from people who register to play basketball in an event. The additional entries are from about a dozen or so people who didn't pay when they initially registered and didn't see the link that takes them directly to pay without registering. In using SELECT DISTINCT, my minor dilemma is one time they might type in for their school, ex: Lebanon, the first time, but Lebanon High School the second time. Columns: id | nameFirst | nameLast | school So if this is my query: select distinct nameFirst,nameLast,school from fallLeague2021 where player_coach ='player' order by nameLast,nameFirst ...is there a way using SELECT DISTINCT to just check the first and last names, then going about business as usual on the other columns? it's a minor issue as currently situated, because it's only about 12 or so entries out of 400, but it would nice if there was an elegant solution using SELECT DISTINCT.
  14. It was styles.css not style.css 😐 The whole time I was wondering if I was missing a step or if I was implementing it correctly inside the other function. It's working now without putting anything inside the other function(s). As I was searching for results, no one ever said how to apply wp_enqueue to other functions, and no one ever said it didn't have to be. Meanwhile, the whole time my file name didn't match the referenced URL. I always appreciate the time people put into responding, so thank you. Building my first full plugin, rather than just injecting my own code, so I'm learning some new tricks.
  15. When I echo plugin_dir_url( __FILE__ ); it produces the correct pathway to my plugin folder, but it doesn't show style.css in the echo.
  16. Here is the full code so far: (Right now I have /style.css vs. style.css) function wpse_load_plugin_css() { $plugin_url = plugin_dir_url( __FILE__ ); wp_enqueue_style( 'style', $plugin_url . '/style.css' ); } add_action( 'wp_enqueue_scripts', 'wpse_load_plugin_css' ); // This gives us uniformity on how the player's name is displayed and formatted function player_name ($nameFirst,$nameLast,$pid) { echo '<span class="full-name"><a href="/tag/'. strtolower(str_replace("'",'',$nameFirst)) . '-' . strtolower(str_replace("'",'',$nameLast)) .'"><span class="fname">'. $nameFirst . '</span><span class="lname"> ' . $nameLast .'</span></a></span>'; } function test() { global $con; wp_enqueue_style('style'); $query ="SELECT *, GROUP_CONCAT(i.industryName) as industry FROM pm_athlete a JOIN pm_athlete_interest ai ON a.id = ai.athleteID JOIN pm_industry i ON i.id = ai.industryID "; echo '<div class="profile">'; $results = mysqli_query($con,$query); while($line = mysqli_fetch_assoc($results)) { $nameFirst = $line['athleteFirst']; $nameLast = $line['athleteLast']; $industries = explode(",",$line['industry']); player_name($nameFirst,$nameLast,$pid); asort($industries); foreach ($industries as $industryList) { echo '<div class="list_school">' . $industryList; echo '</div>'; } //echo '<li>'. $line['industry'] .'</li>'; } echo '</div>'; //end of profile } add_shortcode('test', 'test'); style.css @charset "utf-8"; /* CSS Document */ .full-name a { color: #ccc; font-size: 100px; } Here is the output link: http://wolomarketing.com/players-home/
  17. Style.css is in the same directory as the file these functions are on. So both are in wp-content/plugins/brand-match/. Function test() queries and outputs User information out of a custom table. It'll be function athlete-bio() shortly. It functionally works, but I want to use 'best practice' way of incorporating CSS.
  18. Creating a WP plugin for third party usage (first time doing this), and typically links to stylesheets are put in the header or in the theme generated options panel. That's fine for personal use but not for this. I found wp_enqueue_style via a search on here, and I'm trying to apply it. Below is the code I have right now. function wpse_load_plugin_css() { $plugin_url = plugin_dir_url( __FILE__ ); wp_enqueue_style( 'style', $plugin_url . 'style.css' ); } add_action( 'wp_enqueue_scripts', 'wpse_load_plugin_css' ); function test() { global $con; wp_enqueue_style('style'); ** the bulk of my code - query and output ** } None of my styling is working at this point. I've cleared the cache, and this early stage, just trying to change the size of fonts. Am I on the right track? (probably not) Thank you.
  19. I'm trying to change all school served email addresses to NULL because they are mostly static and in the schools data table. Some coaches list their non-school email address, so I keep that with them as they change jobs. I'm mostly just trying to clean up the coach data table to make sure I don't have conflicting information. However, the below query is changing all the rows to NULL, including the ones with gmail and yahoo. update a_coach set server = NULL where server != "gmail.com" or server != "yahoo.com" I've also tried it with <> instead of !=. Same result. This seems like it should've been pretty straight forward.
  20. Making those group_concat worked. I understood that I have multiple types in that column, but it was all working accept the decommit part. Still don't understand why decommit part didn't work, even after I removed the commit CASE, but it works now. Thank you.
  21. When I removed the CASE/commit, the decommit still doesn't show up, and those two cases aren't group_concat.
  22. So we're clear on the GROUP_CONCAT, I have the following code dealing with that row: This one deals with the time components. I have a similar one dealing with the colleges. CASE as commit is working and has been since May of 2020. CASE as decommit, which I added last night, is not working. if (isset($line['offers'])) { echo '<div class="college-list">'; // This is for a player who has a List if (isset($line['list'])) { echo '<table><th>Final List</th>'; $listSchools = $line['list']; $listDate = $line['timeList']; // Turn CSV into unordered list $listSchools = explode(",",$listSchools); $listDate = explode(",",$listDate); array_multisort($listSchools,$listDate); foreach (array_combine($listSchools, $listDate) as $list => $ldate) {
  23. How does it separate the 'commit' and work as expected but not the 'decommit'? This is what the output looks like: https://www.courtsideindiana.com/tag/kamari-lands/ The 'commit' triggers the top line of the profile, as well as the asterisks next to the college of choice. He recently de-committed from Syracuse. There are no 'list' instances for this player. Until I added the CASE for 'decommit', this code has been unchanged, working and live on my site since May of 2020.
  • 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.