Jump to content

Jim R

Members
  • Posts

    988
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Jim R

  1. Hey, thanks for replying. This sort of flowed into a new problem. http://www.phpfreaks.com/forums/index.php?topic=331174.0
  2. Probably not unions.
  3. Union query? Learning more about it.
  4. That works, but I just discovered an issue with the data I need. I need to also get WHERE meta_value LIKE '%s2member_level2%' . The count has to be where both those conditions are met with the matching user_id. This is all from the same table.
  5. With the meta_value noted above. Here is the raw data: a:1:{s:6:"county";s:1:"1";} The "1" is the region. Basically, registrants choose what county they live in, and each county is assigned a number of 1-5.
  6. Even if the "region" isn't really a column? I've never dealt with unserialized data before. That was a suggested earlier, and while it works, I'm trying to extend the information presented to my user.
  7. I have about 300 users, and I'm trying to group them geographically according what part of the state their county is in OR if they're reading my site because they have a favorite college team. I've created a page that I want to show the total count for each group. There will be 13 groups, and I'd rather not have 13 queries. Basically, I think, I can't make heads or tails of nested loops. I'd like it to look like this: Region 1 (## members) Region 2 (## members) Region 3 (## members) etc. ... ... ... ... ... I assume there will be IF and ElseIF statements. Here is what I'm starting with, but I can't even get the first group working: $query = 'SELECT * FROM wp_usermeta WHERE meta_key = "wp_1_s2member_custom_fields"'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) { $meta_value = unserialize($line['meta_value']); echo '<div>Region 1 (' . $d1 . ' Users)</div>'; if ($meta_value['county'] == '1' || $meta_value['county'] == '2') { ++$d1; } };
  8. Ok...I'm trying to get it to count the number of relevant items, display the User ID's then show the total number that match. $query = 'SELECT * FROM wp_usermeta WHERE meta_key = "wp_1_s2member_custom_fields"'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) { $meta_value = unserialize($line['meta_value']); if ($meta_value['county'] == '1' || $meta_value['county'] == '2') { $count1=0; foreach ($line as $user) { $count1=$count1+1; echo $user['user_id'] . '<br> '; } echo $count1; } } That code produced: 1 4 w a 41 4 w a 4 It should show: 439 440 2
  9. I haven't read what Muddy linked yet, but it might answer this question. Does the *if*....$line['meta_value'] work if I'm just trying to get part of the data in that field? Here is the raw data: a:1:{s:6:"county";s:1:"4";} From that, I'm going to look for "county" and then figure out if the "#" at the end is 1,2,3,4, or 5.
  10. Here is where I'm starting: SELECT * FROM wp_usermeta WHERE meta_key = 'wp_1_s2member_custom_fields' AND meta_value LIKE '%3%' As the PHP produces the page, I'm going to have 15 different options coming from the meta_value LIKE part. I'm assuming I can set up my 15 different DIVs, each with their own IF statement involving the meta_value. Right? I'm not going to have to have 15 different queries, am I? I assume it would start like this: $query = 'SELECT * FROM wp_usermeta WHERE meta_key = "wp_1_s2member_custom_fields"'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) But from there, I don't know if it's possible to deal with partial data with IF statements.
  11. The column in question, is basically mirroring WordPress category tag ID's, so I could likely copy them over with another query. Right?
  12. Here is the query: UPDATE wp_playerRank SET wpID = REPLACE(wpID,'0','(NULL)'); It didn't do what I wanted, and it basically got rid of every zero, not just lone 0's. So 207 became 27.
  13. I ran a Replace query in my database that didn't produce the results I wanted, not in the least. Is there a way I can undo it???
  14. It might be called object mapping, but I'm not sure. Basically, I'm wanting somewhat of a GUI where the User clicks on an area of the page, and the location of the click is noted (for a database). From there it can be given a value based on whether or not a right click was used vs a left click.
  15. I've tried it without the limit, and it works fine. I use that query elsewhere too without the limit. I just added the limit because I'm reproducing a smaller list on my homepage.
  16. OK...I put it at the end, and while it eliminated the error, I'm not getting any results now. $query = 'SELECT * FROM wp_playerRank WHERE year="2011" ORDER BY rankClass ASC LIMIT 5';
  17. This code works fine without the LIMIT 5, but it lists all the results. With the LIMIT $query = 'SELECT * FROM wp_playerRank WHERE year="2011" LIMIT 5 ORDER BY rankClass ASC'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) { Here is the error I'm getting: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/jwrbloom/public_html/resources/players/rank2011_top5.php on line 26
  18. I "JUST" did that before the notification of your post came through. I had that as an issue on something else a year ago, and it took about three days to get it figure out. It works. Thank you. I'm definitely keeping this topic handy, as I like the exploding idea too for another project.
  19. Still getting the error. Warning: Wrong parameter count for str_replace() in /home/jwrbloom/public_html/resources/wp-playerProfile.php on line 62 Here is the code with the double quotes: echo '<ul>List: <li>'; 62 --> echo str_replace(",","</li>\n<li>" . $line['committed']); echo "\n</li>\n</ul>\n";
  20. Pikachu2000, I'm getting this error: Warning: Wrong parameter count for str_replace() in /home/jwrbloom/public_html/resources/wp-playerProfile.php on line 62 Using this code: echo '<ul>List: <li>'; echo str_replace(',','</li>\n<li>' . $line['committed']); echo '\n</li>\n</ul>\n';
  21. For where I would use it, the format would always be the same. It would be progressive, 2011, 2012, 2013, etc. I would Get the slug, such as commitment-2013, hopefully extract the 2013 part and use it to query another table.
  22. commitment-2011 is a slug via WordPress, and I can Get that from the database. However, I'd just like to use the 2011.
  23. Could the same be done with :: commitment-2011 I'd like to pass the 2011 as a variable.
  24. Is there a way to take data that is listed like a,b,c,d,e and turn that into an unordered list? Basically, I'm going to have a list of schools that will be listed with comma separators. I'll print that data out in two places, one will be printed as it's in the database. The other I would like to echo as an unordered list.
×
×
  • 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.