Jump to content

Jim R

Members
  • Posts

    988
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Jim R

  1. var_dump($slug) is producing NULL In the code I quoted: $slug = single_tag_title(); It isn't assigning the value of single_tag_title to $slug. It's just printing it on the screen. single_tag_title is produced by WordPress taxonomy.
  2. You said use var_dump() so I did and wrote the results for you to read. var_dump($slug); produced => KJ WALTONNULL (css is producing the all caps) I did do "one thing and verified it works". I said in post #17 with simpler query, which I provided in the code box, the WHILE produced every name in the database for $nameFull in the format I defined. That means is produced on the screen KJ WALTON, which should've equaled what the $slug printed, KJ WALTON. The var_dump($slug) printed KJ WALTONNULL So I'll be more specific: I don't know why printing $slug would produce a different result than var_dump(). I would assume that if I knew why, I would be able to solve this for myself, but since I can't, I'm here asking questions.
  3. It's basically the Page slug with null at the end. KJ WALTONNULL Not sure how it would get that, but that's why I'm here asking questions. :-)
  4. I've tried it a different way: $slug = single_tag_title(); echo $slug; $query = "SELECT * FROM a_playerRank"; $results = mysql_query($query); echo mysql_error(); while($line = mysql_fetch_assoc($results)) { $nFirst = $line['nameFirst']; $nLast = $line['nameLast']; $nameFull = "{$nFirst} {$nLast}"; if ($nameFull == $slug) { No more error, but it's still not working. It prints the $slug properly. When I put in a line to echo $nameFull of the IF statement, it prints all of them properly, meaning first name (space) last name, so at some point is it printing a result for $nameFull that equals $slug. However, for the IF statement, it's not recognizing it.
  5. As best as I can tell, all my collations match. I also commented out the line that defines $slug, same error.
  6. ILLEGAL MIX OF COLLATIONS (UTF8_BIN,NONE) AND (UTF8_GENERAL_CI,COERCIBLE) FOR OPERATION '='
  7. Where should I echo the mysql_error()? Here is what it is showing: Line 13 is echo mysql_error($results);
  8. It's not the connection, selected database or table/column. The only time the error arrives is when I add the WHERE condition.
  9. Are we not trying to determine what is causing it? Bad syntax in the query or gathering of results.
  10. @objnoob, I got the same error using your second line. Maybe more information will help: In WordPress, I'm trying to match an Tag archive to the first and last name of the player in a separate data table, where I have profile type information. I had a small plugin I wrote that copied over their tag_id to the separate data table, but a WordPress upgrade broke it. As I was trying to fix it, I figured I could just use Tag Archive name and match it. So it used to work and work well.
  11. I'm trying match data from two different tables. The single_tag_title is producing the results I want via the echo, but I can't seem to get the syntax down in the query. $slug = single_tag_title(); echo $slug; $query = 'SELECT * FROM a_playerRank WHERE CONCAT(nameFirst," ",nameLast) = "$slug"'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) { I get the following error:
  12. I tried to attach a CSV file earlier, but it wouldn't let me.
  13. It's printing 0 for the players with NULL in the "rankPos" column, even though in grouping 1 and 0 I don't have code for it to print rankPos.
  14. Can I have a Select *? I added the other columns I needed. It's printing 0 for the players with NULL in the "rankPos" column, even though in grouping 1 and 0 I don't have code for it to print rankPos.
  15. Do you mean from the database itself? I tried to attach a CSV file.
  16. Any help with this? I've looked up "conditional order by", but I'm not sure it applies to what I'm trying to do.
  17. I tried that first actually. It didn't work. I looked around and found something on Stackflow saying that wasn't used anymore. In testing the rowCount, I realized I had '$result' not '$results' but never went back to mysql_num_rows to test it again. Thanks.
  18. I have a list of players who have committed to play basketball at a college. Above that list, I'd like to print the total number of kids committed so far. I don't think counting inside the Loop will help me print what I want, so I looked into printing the number of returned rows. I came across rowCount, but I'm not able to get the syntax down or even understand how to use it. I get the follow error: Fatal error: Call to a member function rowCount() on a non-object in/home4/####/public_html/resources/commitments/commitment2014.phpon line 8 $query = 'SELECT * FROM a_playerRank WHERE YEAR="2014" AND commit="1" AND state="IN" ORDER BY nameLast'; $results = mysql_query($query); $count = $results->rowCount(); echo '<div class="commit_list">'; echo 'There are '.$count.' kids committed.'; Seems easy enough, but I'm clearly missing something or misusing it altogether. Thank you.
  19. What you suggested for the query worked. It took some trial and error to get it print out the way I wanted it. The troublesome part continued to be that 'pr.commit' applied to players who weren't committed to the school featured in the current Page. http://hoosierhoopsreport.com/pu Here is the final code: // Gets Page title $page = get_the_title(); //echo $page; if(!$con = mysql_connect("localhost","jwrbloom_","redcoach")) { die("Could not connect to database: ".mysql_error()); } mysql_select_db("jwrbloom_hhrplayers", $con); $sql ="SELECT * FROM a_playerRank AS pr JOIN playerCollege AS pc ON pr.id = pc.id_player WHERE pr.year = '2014' AND pc.colleges = '". $page ."' ORDER BY (pr.commit='1' AND (pr.college = pc.colleges)) DESC, pc.offer desc, pr.nameLast"; $results = mysql_query($sql); $position = array ( '1' =>'PG', '2' =>'SG', '3' =>'SF', '4' =>'PF', '5' =>'C' ); $currentCollege = false; $currentOffer = false; echo '<div class="recruitWrap">'; while ($line = mysql_fetch_assoc($results)) { $collegeCommit = $line['college']; if($line['college'] != $page) { $line['college'] = ''; } if($line['college'] == $page && $line['commit'] == '1') { if ($currentCollege !=$line['commit']) { $currentCollege = $line['commit']; echo '<div class="recruitHeader">Committed</div>'; } } elseif ($currentOffer !=$line['offer']) { $currentOffer = $line['offer']; if($line['offer'] == '1') { echo '<div class="recruitHeader">Offered</div>'; } elseif ($line['offer'] != '1') { echo '<div class="recruitHeader">Also recruiting</div>'; } } //if((ISSET ($line['college']) && $line['college'] == $line['colleges']) || !ISSET($line['college'])) echo '<div class="recruitRow"> <div class="recruit">' . $line['nameFirst'] . ' ' . $line['nameLast'] . '</div>'; echo '<div class="recruit recruitHeight">' . $line['feet'] . '\'' . $line['inches'] . '"</div>'; echo '<div class="recruit recruitPosition">' . $position[$line['position']] . '</div>'; echo '<div class="recruit recruitSchool">'; if ($line['city'] !='') { echo $line['city'] . ' (' . $line['school'] . ')'; } else { echo $line['school'] . ' HS'; } echo '</div>'; // city school echo '<div class="clear"></div>'; echo '</div>'; if($line['commit'] == '1' && $line['college'] != $page) { echo '<div class="otherCollege">Committed to '. $collegeCommit .'</div>'; } } echo '<div class="clear"></div>'; echo '</div>'; // recruit wrap ?> Thanks for your time on this issue. I always get great help here, as it seems anything I try comes with a learning curve. At least the issues get more complicated, and I'm pretty good at porting anything I've done in the past over to new projects.
  20. I can easily change the 'y' to '1'. Would you recommend I make it so NULL isn't possible? So it's 1 or 0?
  21. I tried your query, but it didn't change the order. (I took out the headers and just had it print the list.) Mathias should be on top. He is pr.commit = 'y' pr.college = 'Purdue' / pc.colleges = 'Purdue' pc.offer = 'y' McIntosh should be at the bottom pr.commit = 'y' pr.college ='Indiana State' / pc.colleges = 'Purdue' pc.offer = 'y' The other guys on this list are pr.commit = '' pr.college = '' / pc.colleges = 'Purdue' pc.offer = 'y' Dakota Mathias 6’4″ SG Elida HS Bryant McIntosh 6’4″ PG Greensburg HS Committed to Indiana State Alec Brennan 6’9″ PF Milton (Academy) Michael Chandler 6’10″ C Niceville (NW Florida State (JC)) Jabari Craig 6’10″ C Waynesboro (Fishburne Military) Vince Edwards 6’6″ SF Franklin (Middletown) Isaac Haas 7’2″ C Piedmont (Hokes Bluff) Ronnie Harrell 6’6″ SF Denver (East) JP Macura 6’5″ SG Lakeville (North)
  22. I looked for those types of conditions in Order By and came up with Case statements. Before I dig too deep, if what I'm ultimately interested in the top group is pr.college = pc.colleges. At that point pr.commit would be implied, so I wouldn't have to sort by pr.commit. Do you think just using (pr.college = pc.colleges) as the condition would work? Right after the SELECT * statement, what does the condition do for me there? I understand what it does in the Order By statement. Thanks for your time.
  23. Disregard the previous post. :-) What about a Case statement in the Order By?
  24. If I use $line = mysql_fetch_assoc($results) instead of... while ($line = mysql_fetch_assoc($results)) { Can I use multiple WHILEs to parse my data?
  25. I can understand why it would not have enough information More detail about my tables and columns. a_playerRank is my main table, noted as pr playerCollege is a table used to link a player's ID to each school that may be involved with him, noted as pc pr.commit tells us whether or not the player is committed, while pr.college tells which college it is if pr.commit = 'y'. pc.colleges is a school recruiting a player (each kid's id might have 2-12 rows, each with a different school). If a school offers a scholarship, pc.offer = 'y'. It's the ORDER of the results I'm looking to alter. A list of players recruited by the same school. In this case $page = Purdue I'm trying to have three groups within that list Players committed to that school (pr.commit = 'y' pc.offer = 'y' pr.college = $page pc.colleges = $page) Players offered a scholarship by that school (pc.offer = 'y') Players the schools are still evaluating (pc.offer = 'y') That part is easy. Where it gets complicated is if a player commits to another school, I would like to note that. So among players recruited by $page (Purdue), my ORDER BY puts players commit = 'y' first, even though they may be committed to another school. The second two groups will have a mix of players who are or aren't committed to any school, but definitely not committed to $page (Purdue in this instance). (I'll be applying this code on about 20-30 school pages down the road.) Right now, among the list on the page I linked above, two players out of ten are committed. One is committed to $page (Purdue), the other is not. I want the one who isn't committed to $page to show up in one of the other two groups (with the note that he is committed to another school). Can I use a WHILE? WHILE pr.college = $page { } There needs to be a while...else.
×
×
  • 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.