Jump to content

Jim R

Members
  • Posts

    988
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Jim R

  1. level is the column in question of the query.  

    Right now I have

    order by -level.  

    Quote

     

    Player, level

    Mark, 5

    KJ, 2

    Zach, NULL

    Tony, NULL

    Jim, NULL

     

    I want it to be...

    Quote

     

    KJ, 2

    Mark, 5

    Zach, NULL

    Tony, NULL

    Jim, NULL

     

     

    I tried...

    order by -level desc 

    ...when I do that, it push KJ and Mark to the bottom.  

     

    Am I going to have to dig into this with CASE?

     

     

  2. Looking for advice on what to look for.  Likely sorting arrays, but I can't find an example anywhere that matches the basic gist of what I need.  

     

    Multiple people will provide a list.  

    Person 1:

    1.  Team A

    2.  Team B

    3. Team C

    4.  Team D

     

    Person 2

    1.  Team C

    2. Team B

    3.  Team D

    4.  Team A

     

    It goes on from there.

    Each of those teams get a value based on where they are on the list.  1 = 1, 2 = 2, etc.

    So Team A would have 5, Team 4, Team C 4, Team D 7.  

    I want to rank them according to lowest total value to highest.  I assume I'll be using asort, as well as  a foreach loop.  

     

    However, I can't wrap my head around how I would set up the array.  

  3. Soooo...even using an alias, such p.id as pid and s.id as sid caused it to be uneditable because I had two columns with the same name.  

     

    Makes sense regardless, since changing s.id would create issues because I wouldn't be interested in changing the id of that field in a_schools.  Rather use schoolID on the a_players table when a player changes schools.  

     

    I do appreciate your time.  90% of time you guys help directly.  The other 10%, you bring new ideas to the table for me check...and I get lucky. 

  4. 1 hour ago, kicken said:

    Since I'm not all that well versed in this area, I don't really have much insight to provide without trying to setup some more complete test db.  My general advice would be to not use the views for your updates.  At least, not directly.  You could probably still use the view to filter, but update the target table directly.  For example, this fails with the error above:

    Appreciate it, but that's not feasible for my needs.  I don't update multiple players to the same value all that often, never in the rankPos column, rarely in a bulk way for any other column.  That was the other nice thing I had.  When I'd change rankPos for a player, the View would reload, so my rankings were always in order.  

     

    Hopefully someone else will wander and take a look.  

     

     

  5. Example:

    This view is allowing me to edit:

    CREATE ALGORITHM=UNDEFINED DEFINER=`courtana_jwr`@`47.227.210.171` SQL SECURITY DEFINER VIEW `_offers`
    AS SELECT
       `p`.`id` AS `pid`,
       `p`.`nameFirst` AS `nameFirst`,
       `p`.`nameLast` AS `nameLast`,
       `p`.`grade` AS `grade`,
       `s`.`city` AS `city`,
       `s`.`school` AS `school`,
       `c`.`college` AS `college`,
       `c`.`level` AS `level`,
       `po`.`recruit_type` AS `recruit_type`,
       `po`.`time` AS `time`
    FROM (((`a_players_offers` `po` left join `a_players` `p` on((`po`.`playerID` = `p`.`id`))) left join `a_schools` `s` on((`p`.`schoolID` = `s`.`id`))) join `a_colleges` `c` on((`po`.`collegeID` = `c`.`id`))) order by `po`.`time` desc;

     

     

    That's with two left joins and two order by criteria.   I've tried the other View with left joins, still won't edit.  So what's the difference?

  6. 29 minutes ago, kicken said:

    If your view had no joins before then it would have probably worked but now with joins it will not.

    I did have Order By with Joins in these views before, and I have other views, that definitely have Order By with Joins, which I can edit.  I didn't see anything in the documentation you linked that spoke of Order By and Limit.   I saw a reference to "certain types of joins", but it I didn't see the information on it.  

  7. 1 hour ago, kicken said:

    The ORDER By clause in your view was preventing my update attempt from working.  Removing it allowed the update query to function.  Did your queries have the order by clause before?  Have you tried running an update query, or just going by the error your GUI tool is showing?

    Any thoughts on which part of the order by?  Because it's pretty essential to the view.  IIRC, that's the same Order By I've had the whole time.  The only thing that changed was joining the two aau_ tables.  

    1 hour ago, kicken said:

    Likely not related to the immediate problem, but you have a type mismatch in your DB.  a_aau.aau_team_id is a VARCHAR being joined tot a_aau_teams.id which is an INT.  The types should be matching, so you likely want to update your VARCHAR to be an INT as well.

    I forgot to change that.  I really gutted how I was handling players' summer teams.  I wanted more flexibility to create content.  

  8. The View in question:

    CREATE ALGORITHM=UNDEFINED DEFINER=`courtana`@`%` SQL SECURITY DEFINER VIEW `_26_5`
    AS SELECT
       `p`.`id` AS `pid`,
       `p`.`grouping` AS `grouping`,
       `p`.`position` AS `position`,
       `p`.`rankClass` AS `rankClass`,
       `p`.`rankPos` AS `rankPos`,
       `p`.`nameFirst` AS `nameFirst`,
       `p`.`nameLast` AS `nameLast`,
       `p`.`feet` AS `feet`,
       `p`.`inches` AS `inches`,
       `p`.`level` AS `level`,
       `p`.`grade` AS `grade`,
       `s`.`school_name` AS `school_name`,
       `s`.`id` AS `sid`,
       `t`.`aau_team` AS `aau_team`
    FROM (((`a_players` `p` join `a_schools` `s` on((`p`.`schoolID` = `s`.`id`))) join `a_aau` `a` on((`p`.`id` = `a`.`playerID`))) join `a_aau_teams` `t` on((`t`.`id` = `a`.`aau_team_id`))) where ((`p`.`grade` = '26') and (`p`.`position` = '5') and (`p`.`grouping` is not null)) order by `p`.`grouping` desc,-(`p`.`rankPos`) desc,`p`.`nameLast`;

    a_aau table

    CREATE TABLE `a_aau` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `playerID` int(2) DEFAULT NULL,
      `aau_uniform` int(3) DEFAULT NULL,
      `aau_team_id` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `Team/Player` (`aau_team_id`,`playerID`)
    ) ENGINE=InnoDB AUTO_INCREMENT=360 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

    a_aau_teams

    CREATE TABLE `a_aau_teams` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `aau_program_id` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
      `aau_team` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
      `aau_year` int(2) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

    a_players

    CREATE TABLE `a_players` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `grouping` int(1) DEFAULT NULL,
      `position` int(1) DEFAULT NULL,
      `nameFirst` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
      `nameLast` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
      `feet` int(1) DEFAULT NULL,
      `inches` int(2) DEFAULT NULL,
      `schoolID` int(30) DEFAULT NULL,
      `grade` int(4) DEFAULT NULL,
      `key_player` int(2) DEFAULT NULL,
      `top_player` int(2) DEFAULT NULL,
      `varsity` int(1) DEFAULT NULL,
      `level` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
      `rankClass` int(2) DEFAULT NULL,
      `comment` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
      `devPos` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
      `rankPos` int(3) DEFAULT NULL,
    
      PRIMARY KEY (`id`),
      UNIQUE KEY `Duplicate Player` (`nameFirst`,`nameLast`,`schoolID`)
    ) ENGINE=MyISAM AUTO_INCREMENT=2283 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

    a_schools

    CREATE TABLE `a_schools` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `gym` int(1) DEFAULT NULL,
      `toggle` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
      `region` int(4) DEFAULT NULL,
      `city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
      `school` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
      `school_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=445 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

     

  9. (Disclosure:  These kids have all had their names published in game programs for the public to view.)

    The error is noted in the picture.  "Field has no or multiple table or database."  

    I would get it if it didn't let me edit the columns I used to join the tables, but I'm not.  I can't edit any of them.  In my other views, I can.  

    Screenshot 2023-05-15 at 9.15.41 AM.png

  10. 7 hours ago, kicken said:

    I don't typically use updatable views, so I'm not sure.  I don't see anything off hand.  Is the query referencing other views, or only real tables?  Does the query return multiple rows for the same p.id value?

    I don't see anything off hand either.  It doesn't query other Views, just real tables.  It doesn't have repeated columns, requiring aliasing other than id.  I had read that page you linked a couple of times throughout the day.  I use this version for 20 different views, 5 positions across the 4 different grades, and I edit grouping and rankPos a great amount as they progress through high school.  

    This views had worked before, but I added the joins to a_aau and a_aau_teams, changing how I derived which summer/travel/AAU basketball team they play for.  It broke the previous view, which I figured it would.  

    When I use the query to create the View.  I can edit the query results.  (I use Sequel Pro.)

  11. I've created a number of views that were editable.  I reconfigured how I handled one aspect and had to redo some of my views.  They are now uneditable.  

    Specifically, two columns (grouping and rankPos) are updated a lot.  Occasionally s.id is too. 

    What about this structure would make it uneditable?

     

    select 
    p.id as pid,
    p.grouping,
    p.position,
    p.rankClass,
    p.rankPos,
    p.nameFirst,
    p.nameLast,
    p.feet,
    p.inches,
    p.level,
    p.grade,
    school_name,
    
    s.id as sid,
    aau_team
    
    from a_players p
    
    JOIN a_schools s
    	ON p.schoolID = s.id
    JOIN a_aau a
    	ON p.id = a.playerID
    JOIN a_aau_teams t
    	ON t.id = a.aau_team_id
    
    WHERE grade = 26 && position = 5 && grouping IS NOT NULL
    	
    ORDER BY grouping desc,-rankPos desc,nameLast

     

  12. 7 hours ago, kicken said:

    You'll have to determine the source of them.  Browser's developer tools should help with that.  My guess would be some sort of margin.  Such gaps don't appear when using the example code from above.

    If you can't find the issue, you'll need to provide updated HTML and CSS code, or a fiddle link, that re-creates the issue.

     

    For some reason the border-radius of the last instance is creating it.  When I turn it off it disappears. 

     

    I did on the last instance, margin-top: -1px; 

     

    It worked. 

  13. 5 hours ago, kicken said:

    The container needs to contain only your .update_card elements, and those elements must be direct children of the container.

    Your original HTML doesn't meet those requirements.  The .blw element also contains your .update_grade element (which is the :first-child).  Your screenshot suggests every .update-card is wrapped in some other parent element (hence, they all are :last-child of that container).

     

    Makes sense, but it has to include update_grade because I'm cycling through multiple players in multiple grades.  In theory it's unavoidable because I don't control how many players my User bookmarks.  

    I was wrong though on one point, the .blw isn't a container.  It's just a way to set update_card apart from other parts of the site. 

     

    Seems like there would be something to the effect of .update_card:nth-of-type(first) / (last).

     

     

     

     

     

  14. 2 hours ago, kicken said:

    If you wrap all your update card elements in a container, and have them all be siblings, then you can get the effect you want using :first-child and :last-child

    blw is the container.  

     

    I have a few similar containers housing update_card instances.  

     

    .blw .update_card:first-child {
    	border-radius:  10px 10px 0px 0px;
    }
    
    .blw .update_card:last-child {
    	border-radius:  0px 0px 10px 10px;
    }

     

    This is what it produced:

     

    image.png.1e152d843c4ff1cff0e8296974e7f95b.png

  15.  

     

    <div class="blw">
    
    <div class="update_grade">Class of 2023</div>
    
    
    
    <div class="update_card">
    
    <div class="update_name"><span class="pName"><a href="/tag/jalen-hooks">Jalen Hooks</a></span>
    
    </div>
    
    <div class="update_information">6'7", <span class="update_position"><a href="/scout/player-rankings/?position=4&amp;grade=23">Power Forward</a></span>  ||  Warren Central</div>
    
    
    </div>  // end update_card
    
    </div> // end blw

     

  16. Other styles are working on them, and one of the changes I've made today in altering its look is removing the border-radius from all four corners of each instance.  

     

    At first I tried nth-of-type(#), but it almost seemed like it was working in reverse.  That doesn't work though because the list in each class won't have the same names. 

  17. Each of those names with information are on .update_card

    Since these lists will vary based on the user, I would like the first instance to have rounded corners at the top, and I'd like the last instance to have rounded corners at the bottom.  

    CSS is below that I've tried...

    image.thumb.png.4aa2d9377b2e122cfd93b3e37cf54405.png

     

    I've also tried first-of-type, last-of-type.  Below is what I have now, which also doesn't work.  

    .update_card {
    	padding-left: 5px;
    	margin-right: 10px !important;
    	padding-bottom: 15px;
    	background: #ccc;
    }
    
    .update_card:first-child() {
    	border-radius:  10px 10px 0px 0px;
    
    }
    
    .update_card:last-child() {
    	border-radius:  0px 0px 10px 10px;
    }

     

     

×
×
  • 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.