I have a very strange issue...

Codes here !

Moderators: egami, macek, gesf

Post Reply
Jwrbloom
New php-forum User
New php-forum User
Posts: 2
Joined: Sun May 10, 2020 6:50 am

Sun May 10, 2020 7:08 am

I have no idea how this happens. The image below is of dynamic content. It's all database generated -- MySQL. While I've learned some new tricks the last few weeks, I've producing these kinds of tables for years.

The first function listed below is creating all the [O] next to players' names. Hover over them, and it will show the list of colleges which have offered them scholarships. The function also determining which players are Committed to a college, which should be printed right below the player's name -- if applicable, and until this morning, it was working just fine.

The gray background print, created by the 'committed' function below, each one of them is one cell lower than it should be.
  • Indiana State should be in the same cell as Lincoln Hale
  • Indiana (Baseball) should be in the same cell as Colson Montgomery
  • Butler should be in the same cell as Blake Barker
The only changes I made this morning are trying to create the (Baseball) part, which is determined by the 'other' column.
Screen Shot 2020-05-10 at 10.53.10 AM.png
Screen Shot 2020-05-10 at 10.53.10 AM.png (58.3 KiB) Viewed 307 times

Each one of those gray background items is associated to a player I noted above. I've checked the IDs. Everything is correct.



I'm quite sure it's not the cleanest code in the world, but below are the two functions.

Code: Select all


// College offers and lists
function college_lists ($colleges,$list,$commit) {
global $pid,$commit;
include(ABSPATH ."resources/con.php");

		$query = "SELECT *,p.id as pid,po.playerID as offerID,	

					GROUP_CONCAT(
						CASE
							WHEN recruit_type = 'Offer' THEN c.college					
						END) as offers,
					GROUP_CONCAT(
						CASE
							WHEN recruit_type = 'List' THEN c.college		
						END) as list,	

						CASE
							WHEN other IS NOT NULL THEN concat(c.college,' (',other,')')
							WHEN recruit_type = 'Commit' THEN c.college
						END	as commit						
						
				FROM a_players p
				
				LEFT JOIN a_schools s
					ON p.schoolID = s.id

				LEFT JOIN a_players_offers po
					ON po.playerID = p.id
		
				LEFT JOIN a_colleges c
					ON po.collegeID = c.id
				
			WHERE p.id = '". $pid ."'";

// AND other <>'' THEN concat(c.college,' (',other,')')
//							ELSE c.college				


		$results = mysqli_query($con,$query);
		while($line = mysqli_fetch_assoc($results)) {
	
			
			$colleges = $line['offers'];
			$commit = $line['commit'];
			$list = $line['list'];
			
						
			if(is_null($commit) && isset($colleges)) {
						if(isset($list)) {
							echo '[L]';
							$offersList = $list;

						}	
						else {
							echo '[O]';
							$offersList = $colleges;
							
						}
				
								if (isset($colleges)) {
		
									if (isset($list)) {
										echo '<div class="list_tooltip"><div class="list_tooltip_header">Final List</div>';
									}
									else {
										echo '<div class="list_tooltip"><div class="list_tooltip_header">Offers</div>';			
									}			

										// Turn CSV into unordered list
										$offersList = explode(",",$offersList);
										asort($offersList);
										foreach ($offersList as $offers) {
											echo '<div class="list_school">' . $offers;
											echo '</div>';	
										}
								echo '</div>';					
							}  // Close the list of colleges check
				
					}  // Close List or Offers if
		}

}

function committed () {
global $commit;

		if($commit) {
			echo '<div><span class="commit">'. $commit;
			
			echo '</span></div>';
		}
	
}

I inspected the elements, and it's definitely not a CSS issue. They are being printed in the cell/row below where they should be. I have no clue how that happens, let alone how to correct it.
Jwrbloom
New php-forum User
New php-forum User
Posts: 2
Joined: Sun May 10, 2020 6:50 am

Sun May 10, 2020 8:41 am

Never mind, I figured it out. I still have ZERO clue why it was doing that, but I create a separate query for the committed function.

I would welcome an explanation as to why I had the problem above. It seems the only real difference is deriving the $commit directly in the function vs. having it passed through globals. It should have no impact on the layout, especially in regards to layout within a table cell.
Post Reply