Jump to content

Jim R

Members
  • Posts

    988
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Jim R

  1. It tells me it doesn't work, and when that syntax worked above, I went with it. I have not problem stipulating I don't know code very well. That's why I'm here. I didn't come here asking for anyone to write it. I'm trying to get at why it's wrong or not working. I removed the brace as you suggested. It gave me an error. :-) I removed the ending brace, and it didn't change my result beyond not having the error anymore. Perhaps it was originally a mistake, as I also took it off the section above, which had no change to my results, but that code was provided by one of the mods here. And for what it's worth, the PHP Manual shows the syntax as: foreach ($arr as &$value) { $value = $value * 2; }
  2. I took the bracket away and got an error. It's the exact same syntax as the section above, which worked, not only in terms of results but also relative to syntax.
  3. Because that's how the part above was coded just after the 'foreach'. It worked in determining Regions, so I tried to copy it for the Reasons(colleges). :-)
  4. When I put right after the foreach, I get the following: So I am getting something. foreach($reasonData as $reason => $reasData) echo '<p>' . var_dump($reason) . '</p>'; {if ($reason !=0) { echo 'College {$reason}<br>\n'; foreach($reasData as $subscription_type => $member_count) { echo '{$subscription_type}: {$member_count} members<br>\n'; } } } echo '</p></div>';
  5. var_dump($reason) produces nothing, which I presumed would be the case. The top section worked, and I tried to 'port it' to the second section, changing the variables as I felt were appropriate, but it didn't work. I can't always/usually get my head wrapped around foreach loops.
  6. Keep in mind, I've tried the variables with alias and without. No effect since none of the columns are redundant.
  7. The top portion came with help from here. I added the var_dump above it to show that the var_dump I'm getting on the second part appears to be working at least to that point. I have taken the first part and tried to duplicate it for the second part. The problem with the second part comes in that it doesn't print out. Here is the output: Here is the code: <link href="/styles/regions.css" rel="stylesheet" type="text/css" /> <?php mysql_select_db("jwrbloom_hhr"); $subscriptionLevels = array( 's2member_level2' => 'Yearly', 's2member_level1' => 'Semi-annual' ); // These are the Reasons. Users decide if they are high school fans or fans of colleges. If they are hsbball fans, they go in part one and are divided up by Region and subscription level. (That is working fine) If they are fans of the others, they go into part two and divided up by subscription level. $collegeSubs = array( 'hsbball' => 'High School', // actually, if they are hsbball, they are in the first part the rest are divided up for the second part 'bsu' => 'Ball State', 'bu' => 'Butler', 'cross' => 'Crossroad Conference', 'ue' => 'Evansville', 'glvc' => 'Great Lakes Valley', 'iu' => 'Indiana', 'ipfw' => 'IPFW', 'iupui' => 'IUPUI', 'isu' => 'Indiana State', 'nd' => 'Notre Dame', 'pu' => 'Purdue', 'valpo' => 'Valparaiso' ); $query = 'SELECT um.meta_value as level, um.meta_key, u.* FROM wp_usermeta AS um JOIN wp_users AS u ON um.user_id = u.ID WHERE u.region IS NOT NULL AND u.reason IS NOT NULL AND um.meta_value LIKE "%s2member%" GROUP BY u.ID asc ORDER BY reason,region,user_login'; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $user_region = $row['region']; $user_reason = $row['reason']; // Keep this - This determines the subscription of level of the user $level = unserialize($row['level']); $level_desc = key($level); //E.g. s2member_level3 if ($level_desc != "s2member_level4") { $user_level = $subscriptionLevels[$level_desc]; } // This ends the subscription level of the user // Here we start to figure out how many subscribe to each level for the first part if($user_reason == 'hsbball') { if(!isset($regionData[$user_region])) { $regionData[$user_region] = array_fill_keys($subscriptionLevels, 0); } $regionData[$user_region][$user_level]++; //end if } // Here is where we start to figure out how many subscribe to each level in the second part elseif($user_reason !='hsbball') { if(!isset($reasonData[$user_reason])) { $reasonData[$user_reason] = array_fill_keys($subscriptionLevels, 0); } $reasonData[$user_reason][$user_level]++; //end else } } //Output the HS Region results (first part) This is the part that works. echo '<div class="region">'; var_dump($regionData); foreach ($regionData as $region => $data) {if ($region != 0) { echo "<br>Region {$region}<br>\n"; foreach($data as $subscription_type => $member_count) { //var_dump($subscription_type); echo "{$subscription_type}: {$member_count} members<br>\n"; } } } echo '</div>'; //Output the College results (second part) None of this shows up beyond the var_dump. REGIONS aren't used here. echo '<div class="reason"><p>'; var_dump($reasonData); // This shows the data similarly to the first part above foreach($reasonData as $reason => $reasData) {if ($reason !=0) { echo 'College {$reason}<br>\n'; foreach($reasData as $subscription_type => $member_count) { echo '{$subscription_type}: {$member_count} members<br>\n'; } } } echo '</p></div>'; ?>
  8. Like I said, when I changed $confirm = wordwrap($message, 70); to $confirm = wordwrap($confirm, 70); It worked. I changed the language of the email's body, but here is the code for the second email being sent: // Confirmation email to the player $confirm = 'Hello, This is to confirm that ' . $_POST['nameFirst'] . ' ' . $_POST['nameLast'] .' has entered the Metro Indy Basketball Fall League. Thank you for entering. If you have not paid yet, you can do so at http://metroindybasketball.com/payment. Information on which team your son will be on and any updates will be posted at http://metroindybasketball.com, or you can also follow us at Twitter: @MetroIndyBBall or follow the search term #MIBFL. If you would like to see a list of those who are committed to play, you can check that out at http://metroindybasketball.com/committed. The #MIBFL starts Sunday, September 30, and runs through Sunday, October 28. We will post rosters the week leading up to the first day, likely on that Wednesday. Once the league starts, the website is also where you will find results. We are looking forward to the start of our sixth season! Thank you again for registering, Name Here'; // In case any of our lines are larger than 70 characters, we should use wordwrap() $confirm = wordwrap($confirm, 70); $confirmHeaders = "From: Metro Indy Basketball <basketball@metroindybasketball.com>"; // Send mail($_POST['email'], '2012 Fall League Registration', $confirm, $confirmHeaders);
  9. Figured it out. The issue I had was the line you copied last. The $message,70 needed to be $confirm,70. Thanks.
  10. That wraps the email message after 70 characters in the event of a longer message. The $confirm is what I altered from $message for the second email.
  11. I have an HTML form set up, processed by PHP to enter information into a database and send me a confirmation email. It's worked great for two years, but I'm getting to the numbers where I'd like to have a separate confirmation email sent to the User after they register. Most of what I search for online, here and at PHP Manual sets up sending the same message to multiple people. Here is what I have being sent to me: // Email to me $message = $_POST['nameFirst'] . " " . $_POST['nameLast'] ." has entered the fall league.\n"; $message .= $_POST['feet'] . "'" . $_POST['inches'] ."\", " . $_POST['grade'] . "; " . $_POST['school'] ."\n"; $message .= $_POST['nameParent']."\n"; $message .= $_POST['email']; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); $headers = "From: " . $_POST['nameFirst'] . " " . $_POST['nameLast'] . " <" . $_POST['email'] . ">"; // Send mail('basketball@metroindybasketball.com', '2012 Fall League Registration', $message, $headers); Below is what I'm trying to send to my Users. I thought changing the variables would create the separate emails, but all I'm getting is the above email twice. // Confirmation email to the player $confirm = "This is to confirm that" . $_POST['nameFirst'] . " " . $_POST['nameLast'] ." has entered the Metro Indy Basketball Fall League.\n\n"; $confirm .= "Thank you for entering. Information on which team your son will be on and any updates will be posted at http://metroindybasketball.com around Wednesday, the week leading up to the start of the league. It starts Sunday, September 30. You may also follow us on Twitter: MetroIndyBBall and search for #MIBFL.\n\n"; $confirm .= "We are looking forward to the start of our sixth season!\n\n"; $confirm .= "Take care,\n\n"; $confirm .= "My Name Goes Here"; // In case any of our lines are larger than 70 characters, we should use wordwrap() $confirm = wordwrap($message, 70); $confirmHeaders = "From: Metro Indy Basketball <basketball@metroindybasketball.com>"; // Send mail($_POST['email'], '2012 Fall League Registration', $confirm, $confirmHeaders);
  12. Yeah, thanks. It's little crap like that frustrate me. It still didn't unserialize the data, as it did for $custom, which you helped me with. The code PFMaBiSmAd provided, where would I put that? Just not sure where it fits: SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING(wp_s2member_custom_fields,LOCATE('s:6:"reason";s:',wp_s2member_custom_fields)),'"',4),'"',-1);
  13. Before revisited the topic, I tried another shot at it: (no avail) I took what Psycho had helped me with earlier in the year and tried to expand it by adding: // ***** Trying to determine why someone is subscribing $reason = unserialize($row['c_reason']); $user_reason = $reason['reason']; if ($user_reason = "iu") { echo $row['user_login'] . ' '; } // ****** end Reason testing area It just prints all the user names. I figured if it didn't work, it wouldn't print any of them. The entire code is below: $subscriptionLevels = array( 's2member_level3' => 'Yearly', 's2member_level2' => 'Semi-annual', 's2member_level1' => 'Monthly' ); $query = 'SELECT um1.meta_value as custom, um2.meta_value as level, um3.meta_value as c_reason, u.ID, u.user_login, u.user_email FROM wp_usermeta um1 INNER JOIN wp_usermeta um2 INNER JOIN wp_usermeta um3 ON um1.user_id = um2.user_id JOIN wp_users u ON um1.user_id = u.ID WHERE um1.meta_key = "wp_s2member_custom_fields" AND um2.meta_value LIKE "%s2member_level%" GROUP BY um1.user_id'; $result = mysql_query($query); //Process results into temp array $regionData = array(); while($row = mysql_fetch_assoc($result)) { //var_dump($row); $custom = unserialize($row['custom']); $user_region = $custom['county']; $level = unserialize($row['level']); $level_desc = key($level); //E.g. s2member_level3 // ***** Trying to determine why someone is subscribing $reason = unserialize($row['c_reason']); $user_reason = $reason['reason']; if ($user_reason = "iu") { echo $row['user_login'] . ' '; } // ****** end Reason testing area if ($level_desc != "s2member_level4") { $user_level = $subscriptionLevels[$level_desc]; } if(!isset($regionData[$user_region])) { $regionData[$user_region] = array_fill_keys($subscriptionLevels, 0); } $regionData[$user_region][$user_level]++; } //Output the results foreach ($regionData as $region => $data) {if ($region != 0) { echo "<br>Region {$region}<br>\n"; foreach($data as $subscription_type => $member_count) { //var_dump($subscription_type); echo "{$subscription_type}: {$member_count} members<br>\n"; } } }
  14. Where would that go in the current code?
  15. Does it need to be different from what is above? What I have posted above works perfectly without the extra of trying to figure out why (what they are a fan of) someone is subscribing.
  16. I don't know what else to say than what I started the topic with. (Other than saying it creates an ordered list--it doesn't--just the groupings above.) I'm going to have 12 "reasons". For 11 of them, it's going to list the "reason" and break down Yearly, Semi, Monthly. The 12th one is "hsbball", under that "reason" it will continue to print what's above. I figured it would be something like: If "hsball" { what's printed above } else { 11 other reason groups }
  17. Just what I have above. I just need to add the extra condition which is part of the serialized data.
  18. Can't I just get help on the question I asked? What you linked doesn't apply to my needs, and I'm not the only one asking about serialized data on this forum.
  19. And if I knew how to do any of that, I'd do it. I don't know why choose to write it as they did, but it's an extension beyond the core offering of the plugin. I also don't know how to rewrite the plugin so upon creating custom registration fields, instead of producing serialized data, it creates new data table columns and populates them accordingly. It's a WordPress plugin. If there is a plugin that creates custom registration fields and use their own columns for data, that would be awesome. However, right now what I'm using is part of a great User Management plugin that also happens to let me create custom registration fields. I don't think they planned on anyone using it as narrowly as I'm trying to. That said, I need help with my extra level of sorting. :-)
  20. I don't mean to sound dismissive, but I think I had this discussion the last time. That's how a very robust payment/User management plugin I'm using inputs the data into the datatable for custom registration fields. I actually wrote the query, but it's been awhile, and I couldn't get it to output as I wanted it to. After looking at it for a couple of days, I can't wrap my head around adding the extra trigger/condition/etc. to sort and group Subscribed Users.
  21. I'm weak with serialized data. The code below is also through a lot of help on here, and it queries two rows from the same data table for each User. I need to add an extra layer or trigger to my output. Right now the code determines: 1) Determine who has subscribed 2) Among subscribers, which region they live in relative to their county of residence. It generates an ordered list: $subscriptionLevels = array( 's2member_level3' => 'Yearly', 's2member_level2' => 'Semi-annual', 's2member_level1' => 'Monthly' ); $query = 'SELECT um1.meta_value as custom, um2.meta_value as level, u.ID,u.user_login, u.user_email FROM wp_usermeta um1 INNER JOIN wp_usermeta um2 ON um1.user_id = um2.user_id JOIN wp_users u ON um1.user_id = u.ID WHERE um1.meta_key = "wp_s2member_custom_fields" AND um2.meta_value LIKE "%s2member_level%" GROUP BY um1.user_id'; $result = mysql_query($query); //Process results into temp array $regionData = array(); while($row = mysql_fetch_assoc($result)) { //var_dump($row); $custom = unserialize($row['custom']); $user_region = $custom['county']; $level = unserialize($row['level']); $level_desc = key($level); //E.g. s2member_level3 if ($level_desc != "s2member_level4") { $user_level = $subscriptionLevels[$level_desc]; } if(!isset($regionData[$user_region])) { $regionData[$user_region] = array_fill_keys($subscriptionLevels, 0); } $regionData[$user_region][$user_level]++; } //Output the results foreach ($regionData as $region => $data) {if ($region != 0) { echo "<br>Region {$region}<br>\n"; foreach($data as $subscription_type => $member_count) { //var_dump($subscription_type); echo "{$subscription_type}: {$member_count} members<br>\n"; } } } What I need it to do is: 1) Determine who has subscribed (which it already does) 2) Determine what they are a fan of (reason) high school basketball or any of 10 colleges in Indiana 3) If they are a fan of any of the colleges, group them accordingly 4) If they are a fan of high school basketball "hsbball", group them according which region they live in Below are the two rows of data for each User is queried. There are 12 different "reasons", determined in the first row. In the second row, that's what determines if a User has subscribed. I have that part taken care of above. meta_key meta_value wp_s2member_custom_fields a:2:{s:6:"reason";s:2:"ue";s:6:"county";s:1:"4";} wp_capabilities a:1:{s:15:"s2member_level2";s:1:"1";}
  22. Never mind, I found the original set of posts helping me figure it out.
  23. I had created this plugin with some help here, but somehow it's been lost from my local drive and server (computer change, as well as an unrelated accidental deletion of files from my server). Here is what I'm trying to do: Author writes Post and puts in Tags (usually names of basketball players). Plugin gets the Tag ID and Slug. Plugin copies the Tag ID to the matching name in a separate data table. I've activated the plugin and tested it. I'm not getting any errors, but it's not updating the other data table. function save_post($post_ID) { mysql_select_db("jwrbloom_hhr"); $wp_tagID = get_query_var('tag_id'); $wp_slug = get_query_var('tag'); $query ="UPDATE wp_playerRank SET wpID = '$wp_tagID' WHERE wpSlug = '$wp_slug'"; return $post_ID; } add_action('publish_post', 'save_post');
  24. Ok...that may explain the var_dump, but I'm still not getting the same result on my page query vs. the query made in my MySQL program. I moved the var_dump up higher and get this: resource(352) of type (mysql result)
×
×
  • 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.