Jim R
Members-
Posts
988 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Jim R
-
I am also trying to get help on the WordPress forums too.
-
Let me start by saying this is my attempt at coding with anything involving a Join, on my own at least. It's failed. : ) I'm trying to match the Tags of Images so they show up on the related Tag Archive page (mostly basketball players for me). I know the first line works and brings the tag_id in so it can be used. The datatable where the images are stored is wp_ngg_pictures. Logically it goes like this: np.pid (128,140,147) = tr.object_id (128,140,147) tr.term_taxonomy_id (1200) = tt.term_taxonomy_id (1200) tt.term_id (where taxonomy = ngg_tag) (517) = t.term_id (where t.term_id = $wp_tagID) (517) $wp_tagID = get_query_var('tag_id'); $qImage = 'SELECT * FROM wp_ngg_pictures AS np LEFT JOIN wp_term_relationships AS tr ON np.pid = tr.object_id LEFT JOIN wp_term_taxonomy_id AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id LEFT JOIN wp_terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = ngg_tag AND t.term_id = "$wp_tagID" '; $pImage = mysql_query($qImage); while($images = mysql_fetch_assoc($pImage)) { <-- line 109 <--- echo $images; } I'm getting this error:
-
Continuing with this project, I need to alter a column in one table based on what it matches in the other. tables are: wp_term_taxonomy_test wp_term_taxonomy UPDATE wp_term_taxonomy_test SET wp_term_taxonomy_test.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id WHERE wp_term_taxonomy.term_id = wp_term_taxonomy_test.term_id The error I'm getting is that wp_term_taxonomy.term_id doesn't exist. However, it does exist. Error Code : 1054 Unknown column 'wp_term_taxonomy.term_id' in 'where clause'
-
Got it. Thanks. SELECT wp_terms.name FROM wp_terms INNER JOIN wp_term_taxonomy USING (term_id) WHERE wp_term_taxonomy.taxonomy = 'post_tag'
-
That just prints all the term. I'm trying to get the ones that just have post_tag as their taxonomy. I tried this, but I get a syntax error. SELECT wp_terms.name FROM wp_terms INNER JOIN wp_term_taxonomy USING (term_id) WHERE wp_term_taxonomy.taxonomy IS (post_tag)
-
That is the table structure as best as I can tell. The two tables are wp_term and wp_term_taxonomy. I'm trying to extract results from "name" in wp_term, where "taxonomy" in wp_term_taxonomy is post_tag, matching them by "term_id", which is in both tables.
-
As I said, I'm not really able to wrap my head around it.
-
I can't seem to wrap it around my head how to get a desired result from querying two tables. I get two or multiple columns but not when it involves two tables. It's a WordPress query. I'm trying to: SELECT name FROM wp_terms WHERE (this is where I stumble)... where taxonomy from wp_term_taxonomy = post_tag AND term_id from wp_term_taxonomy = term_id from wp_teams
-
Database inserted \'s into some of my columns. I need to remove them...
Jim R replied to Jim R's topic in MySQL Help
True, but it was inserted nonetheless. Hard to explain why. Maybe in upgrading the database "version" (whatever that really means), it escapes all single quotes to avoid any conflicts with PHP. It's the only thing I can think of, but it didn't do it earlier. -
Database inserted \'s into some of my columns. I need to remove them...
Jim R replied to Jim R's topic in MySQL Help
Good news. I had backed up my database last week before resetting the first time, and the only changes I've made since then are to non-content pages. If someone wants to answer this question still, I'm sure it can help someone else, or likely me in about a year when I screw something up again. : ) Thanks. -
I was resetting my WordPress database, and while I accomplished what I wanted to accomplish, there were a couple of side effects. One of them was inserting a \ everywhere I have a quote. Considering I deal with the heights of basketball players, 6'1", 6'2", etc., I now have an assortment of \'s showing up all over my site. How do I just get rid of the \'s? I tried to Select the just the cells that had them in a given column, but that didn't work.
-
The following code produced this error: $sql = "SELECT id FROM wp_playerRank_copy WHERE nameFirst='".mysql_real_escape_string($_POST['nameFirst'])."' AND nameLast='".mysql_real_escape_string($_POST['nameLast'])." '"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } if(mysql_num_rows($result)) { while ($row = mysql_fetch_array($result)) /* update existing row */ { $sql = "UPDATE wp_playerRank_copy SET rankClass='".mysql_real_escape_string($_POST['rankClass'])."', hschool='".mysql_real_escape_string($_POST['hschool'])."' WHERE id='".$row['id']."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } } }
-
Where would it go? I tried putting it before the Update, but it just creates a loop that eventually times out.
-
Not sure I understand, but I'll have anywhere from 10-30 rows of data on the screen.
-
I'd rather view it like an editable spreadsheet, where I can edit multiple rows in one setting.
-
I would like one for my iPad, but if I can't find a good one without spending a ton of money, I have to create a way to do it on my site, which I can password protect pretty well.
-
It's definitely just for me, and you ran into the post where I'm trying to build that.
-
What? Where? When? : )
-
Define serious? The ability to add names to my database while I'm away from my laptop will save me a great deal of time in certain moments. I'll be in a gym late tonight, all day on Saturday and all day on Sunday. If at the end of my trip all my new names are tucked away in my database before I even leave the gym, when I get to the hotel or home, I just lay down and go to sleep. I'd just like to do it in spreadsheet form like I do with SQLyog.
-
Ok...that helped, thank you. But as expected, it's just noticing the last row of data. I need it to recognize any/all of the changes.
-
Hopefully I can explain this well. I have a list, which is linked here: http://hoosierhoopsreport.com/test-11-rank/ When I'm done, I'm trying to set up the list I, as ADMIN, can make changes to the list without having to go into my database. I'm mostly concerned with the # column, but once we get through this, I can apply what I've learned. I'm setting the form to print # and school as text fields. I'm getting id, nameFirst and nameLast as hidden values to pass to my form handler. When I hit submit, I'm getting this error: I'm pretty sure it's just filtering through the information to most last piece of data handled, which isn't what I want, but I also don't understand why I'm getting the error. Here is the code dealing with the form: <form id="class2011" action="/resources/form/dbplayerUpdate.php" method="post"> <table class="playerTable" border="0" width="100%"> <thead> <tr> <th class="num">#</th> <th class="top">Top 10</th> <th class="height">HT</th> <th class="pos">POS</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> <tfoot> <tr> <td colspan="8" align="right">(+) moved up; (d) debut; (s) switched from another position / <b>Colleges in bold print means committed</b></td> </tr> <tr> <td><input id="Submit" name="Submit" type="submit" value="Submit" /></td> </tr> </tfoot> <tbody>';$query = 'SELECT * FROM wp_playerRank_copy WHERE year="2011" ORDER BY rankClass ASC'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) { if ($line['rankClass'] != 0) { echo ' <tr> <td> <input type="hidden" name="db_id" value="' . $line['id'] . '"size="2"> <input type="text" name="rankClass" value="' . $line['rankClass'] . '"size="2">' . $line['devClass'] .'</td> <td>'; if ($line['wpID'] > '0') { echo ' <input type="hidden" name="nameFirst" value="' . $line['nameFirst'] . '"size="2"> <input type="hidden" name="nameLast" value="' . $line['nameLast'] . '"size="2"> <a href="/tag/' . $line['nameFirst'] . '-' . $line['nameLast'] .'">'. $line['nameFirst'] . ' ' . $line['nameLast'] . '</a>'; } else { echo $line['nameFirst'] . ' ' . $line['nameLast']; } echo '</td><td>'. $line['height'] . '</td> <td>'. $line['position'] . '</td>'; if (current_user_can("access_s2member_level4")){ echo '<td>'. $line['level'] . '</td>'; } echo '<td><input type="text" name="hschool" value="' . $line['hschool'] .'"size="30"></td>'; if (current_user_can("access_s2member_level4")){ echo '<td>'. $line['summer'] . '</td>'; } if ($line['committed'] == 'y') { echo ' <td><strong>'. $line['college'] . '</strong></td> ';} echo '</tr> ';} } echo ' </tbody></table></form> Here is the form handler: if(!$con = mysql_connect("localhost","jwrbloom_","redcoach")) { die("Could not connect to database: ".mysql_error()); } mysql_select_db("jwrbloom_wpHHR", $con); $nameFirst = $_POST['nameFirst']; $nameLast = $_POST['nameLast']; $db_id = $_POST['db_id']; $rankClass = $_POST['rankClass']; $hschool = $_POST['hschool']; //$grade = $_POST['grade']; //$coachSchool = $_POST['coachSchool']; //$feet = $_POST['feet']; //$inches = $_POST['inches']; /* search for existing row */ $sql = "SELECT id FROM wp_playerRank_copy WHERE nameFirst='".mysql_real_escape_string($nameFirst)."' AND nameLast='".mysql_real_escape_string($nameLast)." '"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } if(mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); /* update existing row */ $sql = "UPDATE wp_playerRank_copy SET rankClass='".mysql_real_escape_string($rankClass)."', hschool='".mysql_real_escape_string($hschool)."', WHERE id='".$row['id']."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } }
-
Anyone have any experience with this? I can't seem to locate anything aside from viewers.
-
When it posts I don't have to worry about the name fields all being the same? From there I just need to associate the changed data to the static data (nameFirst, nameLast, id)?
-
I have a list that goes about 50 deep that I make changes to quite a bit. Each row has five columns, and the information sits on a database. Instead of making the changes in the database, I'd like to make the changes right on my site, so I can actually the list in order, then submit any changes. (It's just easier to look on my web page than the data table, and it's easier to grant the ability to change data on that page than give another data table access.) They are ordered by rankings 1-50. To do that, I'm picturing rows of data, printed in form elements instead of just printed statically on the page. From there I can make the changes I need (mostly to just the one column) then his Submit. Here is how the code looks now: <table class="playerTable" border="0" width="100%"> <thead> <tr> <th class="num">#</th> <th class="top">Top 10</th> <th class="height">HT</th> <th class="pos">POS</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> <tfoot> <tr> <td colspan="8" align="right">(+) moved up; (d) debut; (s) switched from another position / <b>Colleges in bold print means committed</b></td> </tr> </tfoot> <tbody>';$query = 'SELECT * FROM wp_playerRank WHERE year="2011" ORDER BY rankClass ASC'; $results = mysql_query($query); while($line = mysql_fetch_assoc($results)) { if ($line['rankClass'] != 0) { echo ' <tr> <td>'. $line['rankClass'] . $line['devClass'] .'</td> <td>'; if ($line['wpID'] > '0') { echo '<a href="/tag/' . $line['nameFirst'] . '-' . $line['nameLast'] .'">'. $line['nameFirst'] . ' ' . $line['nameLast'] . '</a>'; } else { echo $line['nameFirst'] . ' ' . $line['nameLast']; } echo '</td><td>'. $line['height'] . '</td> <td>'. $line['position'] . '</td>'; I'm primarily interested in $line['rankClass'] being editable right on my web page. I"m seen syntax examples, but they have all been just changing one line at a time. I could theoretically make changes in all 50 rows. From a syntax perspective, I feel like I'm going to run into a NAME issue. Example: <input maxlength="5" name="rankClass" size="2" type="text" /> I realize I need to change "rankClass" to PHP that brings in the value from the data table. However, the PHP would also do that for 50 rows of data. Do I need to worry about duplicate instances being name="rankClass"? How would that look?
-
Yes. Here is what I'm needing to query. $member = 'SELECT * FROM wp_usermeta WHERE meta_value LIKE "%s2member_level%"'; $m_results = mysql_query($member); $custom = 'SELECT * FROM wp_usermeta WHERE meta_key = "wp_1_s2member_custom_fields"'; $c_results = mysql_query($custom); The columns are user_id, meta_key, meta_value. Keep in mind, what Joel put together worked perfectly, but as I went to implement it, I realized I didn't fully understand what I was needing. You might be able to use that as a guide. What he wrote provided a total numbers of Users live in each region (based on which county they live in). The number I need is among those, which ones are subscribers.