Jump to content

Jim R

Members
  • Posts

    988
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Jim R

  1. It is my second usage of mysql_fetch_assoc in the file. I'm a tweaker, not a coder. *shocking, right? * I've never really gotten a grasp of which function to use after my queries, so I basically just use that one. Once I was told to "reset the pointer" on another issue awhile ago. Is that my issue now?
  2. It's a WordPress site, but this still seems more like a PHP/MySQL issue rather than a WordPress issue. I'm trying to match Images (ngp.pid) tags (tr.object_id) that share the same ID's. The Images matched have to then share the same ID as $wp_tagID, which the Page gets based on whatever link my user clicks. From there I want to print what I have to the screen. Here is the test screen: http://hoosierhoopsreport.com/tag/Michael-Volovic/ (All the information above the HR is from a database, linked to $wp_tagID, so I know that part of it is working.) Clicking on his link, carries a $wp_tagID of 677. When I test my query in my MySQL program and just use 677 (as $wp_tagID) it works. I get five images that share the same link of this basketball player. The second var_dump is producing a false result on the actual page. Not sure why. $qImage = ' SELECT * FROM wp_terms AS t JOIN wp_ngg_gallery AS ngg JOIN wp_term_taxonomy AS tt JOIN wp_term_relationships AS tr JOIN wp_ngg_pictures AS ngp WHERE t.term_id = tt.term_id AND ngg.gid = ngp.galleryid AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id = ngp.pid AND tt.taxonomy = "ngg_tag" AND t.term_id = "$wp_tagID" LIMIT 5'; // AND t.term_id = "$wp_tagID" $pImage = mysql_query($qImage); while($image = mysql_fetch_assoc($pImage)) { foreach ($image as $images) { echo '<img src="http://hoosierhoopsreport.com'. $images['path'] .'/'. $images['filename'] .'>'; } } var_dump($wp_tagID); var_dump($image);
  3. Hoping someone can give this a look. Thank you.
  4. Here is the sample page: http://hoosierhoopsreport.com/pg-test/ Trying to create a table that has three sections (groupings). That part I have figured out. The first grouping is sorted numerically. The second group is sorted alphabetically based on what part of the state they live in. It's breaking down this second part that I can't seem to get. (The third group is just what's left over, sorted alphabetically.) So it needs to look like this: (Each group and region have their own header row. Only Group 2 is broken down into Regions.) Group 1 Group 2 -Region 1 -Region 2 -Region 3 -Region 4 -Region 5 Group 3 The sample page above, in Group 2, it just shows Region 1 header. $query = 'SELECT * FROM a_playerRank WHERE year="2015" and position="1" 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">Top 10</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>'; } if($line['grouping']==1) {echo '<tr><th colspan="7">Best of the Rest</th></tr>'; if($currentRegion != $line['region']) { $currentRegion = $line['region']; echo '<tr><th colspan="7">Region' .$line['region'] . '</th></tr>';} } if($line['grouping']==0) echo '<tr><th colspan="7">Names to Know</th></tr>'; }
  5. My apologies. I typed the wrong URL. It shows: http://metroindybasketball.com #3 (line 101). I have since drilled down the to the div ID #top, which worked, but in other instances on other sites, I haven't been able to effectively produce what I want. How would I find that line?
  6. That didn't work because it's being overridden by the http://hoosierhoopsreport.com #3 line 31 style. There is no such line of code that even matches the style. It wasn't a file name. @jesirose, same thing...regular styling for body wasn't working, as it was overridden by the above. I was able to drill down to the div ID, and that worked. I'm surprised, but it works.
  7. Using Firebug to find the style of a certain part of my WordPress theme, it shows the file as my URL http://hoosierhoopsreport.com with a #3 after it and a line number. Where do I find that? I see that a lot actually in various themes. I search all the files and can never the appropriate code. I need to change the body background, and using the override method isn't working. body[style]= #000099 !important; I've also tried it with the semi-colon after the hex code.
  8. True ...but when I set up the form, I wasn't really into databases. I copied entries on to a spreadsheet as they came in. (It's a week long contest.) Their team number and record were just visually part of the answer. Their record is more of an aid to the User, and the team number is also just a reference, indicating where they are in a bracket. I'm OK with that all being part of the answer for now. I'm not really displaying anything beyond the number of correct choices after it's over, and perhaps the number of Users who picked certain teams. Going forward, I'd create a more dynamic form, but for now it's in HTML. Do I need to convert it to php to create the array need to insert into a database?
  9. I think I was editing while you were responding. Sorry about that. The form is set up purely in HTML (.php page) and posts Action to a .php page. I've had the form for about five years. Only now and going forward am I wanting to put the results from Users into a database. This year I'm wanting to put the User's choices in a data table.
  10. Do I need to re-write the form in PHP? Here is a sample drop down with the choices. The "name" is section number I need to insert. I figured I could duplicate that by counting instances in my foreach loop. But sticking to the question at hand, will I need to wrap all 64 of my drop downs in PHP? <select name="1"> <option selected="selected">____select team</option> <option>1. Hammond Morton, 7-13</option> <option>2. Highland, 10-11</option> <option>3. Gary West, 11-10*</option> <option>4. Munster, 20-0</option> <option>5. Lake Central, 12-8</option> <option>6. Lowell, 12-8</option> <option>7. East Chicago Central, 13-7</option> </select>
  11. Should I make all the form items have the same name? (Then use a counter to simulate the section number?)
  12. I've had an online form that would be processed in this way: Insert the User's information - name, email, school - into a database. Then it would email me that information as well as the responses to 64 questions. I'd like to now put those answers in a data table. Here is how those responses would be sent to me, with their form (drop down items) item name: $message .= $_POST['1'] . "\n"; $message .= $_POST['2'] . "\n"; $message .= $_POST['3'] . "\n"; $message .= $_POST['4'] . "\n"; .... ......... all the way down to 64 .... $message .= $_POST['64'] . "\n\n"; I have a data table with the following columns: (user_info) ID nameFirst nameLast email school I have another table with the following columns: (user_answer) --> this is the table I need help on ID uID section --> that corresponds with the form item name answer --> actual answer chosen For each uID, I'll have 64 ID's, so it will be for example: 1 1 1 Munster 2 1 2 Valparaiso ...... 64 1 64 Tecumseh 65 2 1 Lake Central 66 2 2 Merrillville The question I have (it may be a simple one) is how do I get those 64 answers from a User into an Array that I can start building a Loop to Insert?
  13. It wasn't just about the variable but the location of the IF loop. $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"; } } }
  14. I put it in. It didn't tell me anything. Here is what is produced: string(0) "" : 1 members
  15. That's not going to tell me what variable to use. That's just going to confirm what I already know. It doesn't work. As I said, that was just the last variable I tried before posting the code.
  16. If I knew the answer to that, I wouldn't have tried it. Is there a chance instead of telling me what doesn't work, which I already know doesn't work, could you show me what does work? I've tried several of the variables dealing with level, and I've tried that IF in a couple of places. I simply left it as I last tried it and posted the code here so it could be seen as reference. it's reflecting those with s2member_level4 with that line, and there would be others showing if Region 0 (those who hadn't picked a County) was still showing. I took out the s2member_level4 from the first array because it's not going to be used.
  17. Here is the code with comments where I added IF loops: $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 $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) { // This worked, eliminating Region 0 echo "<br>Region {$region}<br>\n"; foreach($data as $subscription_type => $member_count) {if ($subscription_type != "s2member_level4") { // This did not eliminate s2member_level4 row echo "{$subscription_type}: {$member_count} members<br>\n"; } } } } I'm trying to get rid of: Region 4 Yearly: 0 members Semi-annual: 0 members Monthly: 0 members : 1 members <---------- that row there
  18. I got rid of Region 0, but I can't get rid of the s2member_level4 row. I've tried a few variables. $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 $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) {if ($subscription_type != "s2member_level4") { echo "{$subscription_type}: {$member_count} members<br>\n"; } } } }
  19. I come here as my last resort, and I put the problem out there while I work on it. Sometimes I get it by talking through it. Sometimes I don't. I would think a "where" in the foreach loop would make the most sense, but I'm not sure that works. I started to search for it as I sat down then saw the email notification.
  20. I think we're good on the data now. It was the first query you provided, but I added the Group By back. There are more than one record for some of the Users. Not sure why, but I think it could have been due to a change in the plugin. At first, I think it Inserted new rows with each change, where now it updates, because suddenly my last four Users just have one record that matches. Here is what I have now, with your tweaks and initial query. $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 $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) { echo "<br>Region {$region}<br>\n"; foreach($data as $subscription_type => $member_count) { echo "{$subscription_type}: {$member_count} members<br>\n"; } } Here is what it's producing, which is really close to my needs: I need for Region 0 to not show up at all. Also, the rows with just a count (one in Region 4, the other is in Region 0), I need for those not to show. Those represent s2member_level4.
  21. I know what those odd lines are now. They Users with s2member_level4, which shouldn't be part of the print out. That's a different part of the site. I didn't think about that.
  22. You need to explain to me what you mean by data requested if what I've posted isn't good enough. I posted the data in the post that started this topic, and I noted that couple of posts up. THAT's the data the Inner Join needed to get. It's just a sample of the data, but there are over 7,000 rows in that table. I figured just a few might help. As for the other table, I've noted a few times I just need it for user_login and user_email. Each User has anywhere from 20-30 rows associated to their user_id. To keep it simple, just know, that line links the user_id on both sides of the Inner Join, and that is necessary to get the correct count. I've noted that before. What we have now is really close, minus a couple of weird lines.
  23. I added a line break. It has a couple of odd lines. One in Region 0. Another at the end.
  24. Why did you change the query? It worked. I tried your last one without even looking at the query. I just looked at how you were creating the array. Getting rid of um1.user_id=um2.user_id screwed up the count.
  25. I get that, but that aspect of it was still working. I tested it. I put in the aliases as you helped me with the rest of my query. It produced the same results as your changes did. I definitely see the logic of your point though, and I appreciate your help. I'm stepping out for lunch right now and will work on that code when I get back. Thank you!
×
×
  • 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.