Jump to content

Jim R

Members
  • Posts

    988
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Jim R

  1. 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.
  2. 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.
  3. 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?
  4. 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)
  5. 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.
  6. Disregard the previous post. :-) What about a Case statement in the Order By?
  7. 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?
  8. 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.
  9. Could I utilize Case in the Order By part of my query? Order By "commit" where "college" (the college committed to) != "colleges" (the college recruiting him)
  10. Is there a way to take my results assigning value to a variable so I can change where it shows up on my list without altering the database? I can make it not echo the instance I noted above, but I can't change where it shows up. The page title controls one of the query variables, in this case Purdue University. Any player in the database recruited by Purdue will eventually show up on that list. However, most of them will commit to play for another school. I want to be able to reflect that a player has been recruited by one school yet committed to another.
  11. Really it would just be an IF. Here is a link to my page: http://hoosierhoopsreport.com/pu I want the instance of... Bryant McIntosh 6'4" Greensburg Committed to Indiana State ...in the Offered group. This will allow me to reflect where a player decided to attend who was offered a scholarship by the college in the current view. The trigger is the column "commit". When pr.college != pc.colleges (which matches the WordPress page title / $page), it basically says that player did not commit to the college in the current view. They committed somewhere else. Somehow when Bryant McIntosh' instance comes through the query, pr.commit needs to not equal "y" // Gets Page title $page = get_the_title(); //echo $page; $sql ="SELECT * FROM a_playerRank AS pr, playerCollege AS pc WHERE pr.id = pc.id_player AND pr.year = '2014' AND pc.colleges = '". $page ."' ORDER BY pr.commit desc,pc.offer desc,pr.nameLast "; $results = mysql_query($sql); $position = array ( '1' =>'PG', '2' =>'SG', '3' =>'SF', '4' =>'PF', '5' =>'C' ); $currentCommit = false; $currentOffer = false; echo '<div class="recruitWrap">'; while ($line = mysql_fetch_assoc($results)) { if ($currentCommit != $line['commit']) { $currentCommit = $line['commit']; if ($line['commit'] == 'y') { echo '<div class="recruitHeader">Committed</div>'; } else { echo '<div class="recruitHeader">Offered</div>'; } } if ($currentOffer !=$line['offer']) { $currentOffer = $line['offer']; if ($line['offer'] == 'y') { } else { 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['college'] != $page) { echo '<div>Committed to '. $line['college'] .'</div>'; } } echo '<div class="clear"></div>'; echo '</div>'; // recruit wrap
  12. Yes, that makes perfect sense, and in having mismatched variables, it 'worked'. It was weird though, I went awhile with no spam after having some, then it returned a few days ago. I'll be curious to see how long I go now without spam, but there are a couple of patterns the spam is inputting that I could deal with as well should not the do the trick entirely.
  13. OK...I may have found out the problem. And yes, I'm a moron, and as I've posted on here several times this is why coding for a living would a) not be an option, and b) drive me insane: The problem: The field names were mismatched all along "email2" on the form, "Email2" on the enter.php. So when I changed both to "name" it 'stopped' working. It never worked. However, I found a similar solution, and it looks like I did it wrong the whole time: http://www.webdesignerforum.co.uk/topic/68584-anti-spam-form-without-captcha/ Basically, I needed to set up the hidden field with an empty value = '', so if it remained empty keep going, but if a spam bot fills it, stop and say "thanks for playing". Luckily my wild goose chases only happen about twice a year. One time we had this long a$$ discussion with two or three guys trying to help. Each one of us saying there is no reason this shouldn't work. It came down to having a comma instead of a period. Like anything, if you get enough eyes onto the subject, eventually you'll find the solution, even if it makes you look harder at your own code. I had kept the php files open since I made the changes, so I was able to CTRL-Z back to where they were before the change. That's when I noticed the difference in the capital E in Email2. Thank you for your time. I've tested the solution I linked, and it's working great...at least in terms of letting the form go through. We'll see how it does with spam over the next few days.
  14. I understand what you're saying, but keep it on simple terms here. I have a form with a hidden field called "name". The form sends the user to enter.php where it's processed. The first thing enter.php does is... <?php // Make sure this person is real if (ISSET ($_POST['name'])) { echo 'Thank you for playing'; } // If so move on else { $nameFirst = $_POST['nameFirst']; $nameLast = $_POST['nameLast']; $nameParent = $_POST['nameParent']; $email = $_POST['email']; $addressHome = $_POST['addressHome']; $cityHome = $_POST['cityHome']; $stateHome = $_POST['stateHome']; $zipHome = $_POST['zipHome']; $phoneHome = $_POST['phoneParent']; $phoneMobile = $_POST['phoneMobile']; $school = $_POST['school']; $grade = $_POST['grade']; $coachSchool = $_POST['coachSchool']; $feet = $_POST['feet']; $inches = $_POST['inches']; From there it goes on to check if the Registrant is in the database. If so, it updates it. If not, it inserts him. Then it sends out emails and redirects the Registrant to the payment page. Now, if I change "name" to "name1", the form now works because "name1" doesn't get set because there is no "name1" in the form. Registrant information gets sent to database, emails get sent.
  15. I appreciate that thinking, but I didn't change anything else. Even if I had, the ISSET is the first thing on the php file processing the form. It's not getting past the IF...ELSE. Also, mismatching the variable allows the form to work, so once it gets past the IF...ELSE, it works just fine.
  16. The logic is that if the spam bot populates the hidden field, the form isn't really processed. I think I picked up the idea from here somewhere, but I didn't follow or comment on the topic, so I can't find it. I did search for it before I posted this topic. The form is taking information from registrants to participate in a basketball league. Upon successful registration, their name is entered into the database and an emails are sent to them and me. Their names are also put on a published list. I had it up from July 6 to August 13, two days ago, and it was working. Until August 8 or 9, it was keeping spam out, while allowing successful registrations through. That has changed this week. What I'm getting with the spam is gibberish information. I think I can detect a pattern to what it's doing, typically nameFirst = nameLast, but I haven't had any registrations the last two days because of the issue I posted about. It hasn't let any registrations through since I made my change. All I did on the 13th was change the input name of the hidden field from email2 to name, and somehow it's not working anymore. I made no other change to the form, and I made the same change to the php code processing the form. I was hoping changing the name of the field would confuse whatever spam bot had found it's way through. I'm not logging any headers. @darkfreaks, my reCaptcha is through Google
  17. Just to clarify, that method allowed 86 legitimate registrations to go through, and only in the last couple of days had spam started showing up.
  18. I have a form on my site, and captcha isn't really working very well at keeping spam out. I put a hidden field in my form, and that was doing the trick for awhile, but while not as much as before, I was still getting an occasional spam submission. I thought changing the $_POST label would help, but now it won't work. I made no other changes than to the form and the code processing the form. Form HTML: <input name="name" type="hidden" /> **** php file *** if (ISSET ($_POST['name'])) { echo 'Thank you for playing'; } else { //process form } It was "email2". Changing it to "name" has caused it to not work, and no other field is called "name".
  19. First of all, I have a lot of code and WordPress shortcodes determining which User can see which content. My issue is the query and how it's ordered. There are three primary groups: 1) (Top 10) Ordered numerically based on the ranking I give them, typically 1-10. 2) (Best of the Rest) Should be ordered alphabetically based on nameLast. 3) (Names to Know) Is divided into Regions of the state (I have headers for each region), then listed alphabetically. The issue is Group 2. It's being ordered the same as group 3, just without the headers. I tried flipping 'region' and 'nameLast', but that really screwed up group 3. I attached a screenshot of what it looks like. I was surprised I could get the 3rd group the way I wanted it, but now I can't wrap my head around the logic of how to alphabetize the 2nd group. $query = 'SELECT * FROM a_playerRank WHERE year="2014" and position="2" and grouping<4 ORDER BY grouping DESC,rankPos,region,nameLast'; $results = mysql_query($query) or trigger_error('MySQL error: ' . mysql_error()); $currentGrouping = false; $currentRegion = false; while($line = mysql_fetch_assoc($results)) { if($currentGrouping != $line['grouping']) { //Status has changed, display status header $currentGrouping = $line['grouping']; if($line['grouping']==2) { echo '<thead> <tr> <th class="num">#</th> <th class="top"></th> <th class="height">HT</th>'; if (current_user_can("access_s2member_level4")){ echo '<th class="level">Level</th>'; } echo' <th class="school">City (School)</th>'; if (current_user_can("access_s2member_level4")){ echo '<th class="summer">Summer Team</th>'; } echo' <th class="college">College</th> </tr> </thead>'; } elseif($line['grouping']==1) { echo '<tr><th colspan="7">Best of the Rest</th></tr>'; } elseif($line['grouping']==0) echo '<tr><th colspan="7">Names to Know</th></tr>'; } // Determine what region the player plays if($currentGrouping=="0") { if($currentRegion != $line['region']) { $currentRegion = $line['region']; echo '<tr><th colspan="7" class="region">Region '. $line['region'] . ' :: '; if($line['region']==1) echo 'The Region'; if($line['region']==2) echo 'South Bend, Elkhart'; if($line['region']==3) echo 'Fort Wayne, Marion'; if($line['region']==4) echo 'Lafayette, Kokomo, Greencastle'; if($line['region']==5) echo 'Indianapolis metro area'; if($line['region']==6) echo 'East Central Indiana - Muncie, Richmond, as I-74 hits Ohio'; if($line['region']==7) echo 'Bloomington, Terre Haute, Bloomington'; if($line['region']== echo 'Columbus, Madison, Louisville area'; echo '</th></tr>';} } echo ' <tbody>'; if (empty($line['pro']) && ($current_user->ID == 1587)) { } else { //if (isset($line['pro'])) { echo '<tr> <td>'. $line['rankPos'] . $line['devPos'] . '</td> <td class="nowrap">'; if ($line['wpID'] > '0') { echo '<a href="/tag/' . $line['wpSlug'] . '">'. $line['nameFirst'] . ' ' . $line['nameLast'] . '</a>'; } else { echo $line['nameFirst'] . ' ' . $line['nameLast']; } echo '</td><td>'. $line['feet'] . '\'' . $line['inches'] . '"</td>'; if (current_user_can("access_s2member_level4")){ echo '<td>'. $line['level'] . '</td>'; } if ($line['city'] !='') { echo '<td class="nowrap">' . $line['city'] . ' (' . $line['school'] . ')</td>'; } else { echo '<td class="nowrap">'. $line['school'] . ' HS</td>'; } if (current_user_can("access_s2member_level4")){ echo '<td>'. $line['summer'] . '</td>'; } //else //{ echo '<td></td>'; //} echo '<td>'; if ($line['commit'] == 'y') { echo ' <strong>'. $line['college'] . '</strong> ';} echo '</td></tr>'; if (current_user_can("access_s2member_level4")){ if (!empty($line['pro'])) { echo '<td></td><td colspan=6><span class="analysis">'. $line['pro'] . ' :: ' . $line['con'] .'</span></td>'; } } } } echo '</tbody></table></div>';
  20. Trying to execute this query: UPDATE a_playerRank AS p, wp_terms as t SET p.wpID = t.term_id WHERE p.wpSlug = t.slug I get the following error: Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '=' As far as I can tell, applicable columns are utf8_unicode_ci and none are utf8_general_ci. I've searched for solutions here and on elsewhere. Can't make much of what is being suggested.
  21. Oooo...very nice!! That worked, and it even kind of makes sense to me. :-) Thank you to you three who answered!
  22. Got your DM. That code brought it back to where it was before I tried the foreach. It posts the Team Number but no coach's name, then the roster underneath. I left it there so you could see it.
  23. No, I don't have the coaches' names in the database. I figured I could make it work via an array.
×
×
  • 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.