Jump to content

Jim R

Members
  • Posts

    1,006
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Jim R

  1. Ok...I got rid of the errors. There were a few, another comma and two bad variables. HOWEVER, the only value being passed is the one for "content". There is another aspect of this that maybe I didn't understand. In using this code for this site, I have some javascript going on that is suppose to show the submission on the page in real time, without having to refresh. It's working with the...you guessed it...the "content" field. I assumed the JS just created the effect then passed the User to the code that processes the data. Do I have to reflect all the fields I need passed in the JS??? (I don't work with JS at all. It was a open source code.) <script type="text/javascript"> $(function() { $(".comment_button").click(function() { var element = $(this); var boxval = $("#content").val(); var dataString = 'content='+ boxval; if(boxval=='') { alert("Please Enter Some Text"); } else { $("#flash").show(); $("#flash").fadeIn(400).html('<img src="ajax.gif" align="absmiddle"> <span class="loading">Loading Update...</span>'); $.ajax({ type: "POST", url: "/live_update/update_data.php", data: dataString, cache: false, success: function(html){ $("ol#update").prepend(html); $("ol#update li:first").slideDown("slow"); document.getElementById('content').value=''; $("#flash").hide(); } }); } return false; }); $('.delete_update').live("click",function() { var ID = $(this).attr("id"); var dataString = 'msg_id='+ ID; if(confirm("Sure you want to delete this update? There is NO undo!")) { $.ajax({ type: "POST", url: "/live_update/delete_data.php", data: dataString, cache: false, success: function(html){ $(".bar"+ID).slideUp('slow', function() {$(this).remove();}); } }); } return false; }); }); </script>
  2. Status is my last field. Where should a comma go?
  3. Ok...I guess, but it's working quite well on another site, which is currently in the part of the year when it's most used. I've had additions made to it today. The other issue is it's passing the value for "content" but not the other fields.
  4. I have a form that is passing the User to following code. The code below is just ported from another site that I created, which works extremely well. I've had to change the datatable, database connection and some of the variables for this site, but it's otherwise the same. I've triple checked the variables. The datatable is accurate. It doesn't appear to be passing variable from the Form with the exception of "content", and I'm getting the following error: What am I missing? <?php include('db.php'); $playerFirst = $_POST['playerFirst']; $playerLast = $_POST['playerLast']; $feet = $_POST['feet']; $inches = $_POST['inches']; $year = $_POST['year']; $position = $_POST['position']; $content = $_POST['content']; $ppg = $_POST['ppg']; $rpg = $_POST['rpg']; $apg = $_POST['apg']; $spg = $_POST['spg']; $bpg = $_POST['bpg']; $fgp = $_POST['fgp']; $ftp = $_POST['ftp']; $status = $_POST['status']; //if(isSet($_POST['playerFirst']['playerLast']['feet']['inches']['year']['status'])) //{ /* search for existing row */ $sql = "SELECT msg_id FROM players WHERE playerFirst='".mysql_real_escape_string($playerFirst)."' AND playerLast='".mysql_real_escape_string($playerLast)."'"; 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 players SET feet='".mysql_real_escape_string($feet)."', inches='".mysql_real_escape_string($inches)."' year='".mysql_real_escape_string($year)."', position='".mysql_real_escape_string($position)."', content='".$content."', ppg='".$ppg."', rpg='".$rpg."', apg='".$apg."', spg='".$spg."', bpg='".$bpg."', fgp='".$fgp."', ftp='".$ftp."', status='".$status."', WHERE msg_id='".$row['msg_id']."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } } else { /* insert new row */ $sql = "INSERT INTO players SET playerFirst='".mysql_real_escape_string($playerFirst)."', playerLast='".mysql_real_escape_string($playerLast)."', feet='".mysql_real_escape_string($feet)."', inches='".mysql_real_escape_string($inches)."' year='".mysql_real_escape_string($year)."', position='".mysql_real_escape_string($position)."', content='".$content."', ppg='".$ppg."', rpg='".$rpg."', apg='".$apg."', spg='".$spg."', bpg='".$bpg."', fgp='".$fgp."', ftp='".$ftp."', status='".$status."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } }
  5. That was my next question above. Basically I just use If statements for each required field?
  6. I get that, but I have a specific user base, all professionals in the same field, which I know them all by name. In a 12 field form, I just need to make sure they answer those in the least. Four of them are drop downs.
  7. I guess I'm not grasping what you're saying. All I care about is someone not trying to forward an empty field. I'm dealing with a specific User base, coaches. They aren't going to be the type that tries to get cute with entries, and I won't have to worry about checking for specific characters. They will all type in the names, but once they get far enough down their roster, they might try to cut some corners by not submitting height, grade, etc. If they leave a required field blank, I'd have it say to make sure all required fields are filled. If all are filled, the form will make see if the name is already entered. If so, it will treat the submission as an update. If not it will insert a new row of data. I have all of that done except checking for required fields.
  8. "empty" I get. Would I use if...elseif...elseif...etc to cover each entry?
  9. Wait...maybe I screwed something up. I just want to make sure Users fill out those fields before moving on. Most would just fill in the name and try to move on. I have a Live Update set up, so it's showing submissions in real time. I'm just trying to make some fields required. Pikachu, what you have seems to be just a bit more complicated than I really need. Can I check for required fields in the way I posted above?
  10. If I wanted to make multiple fields required before letting a User move past the field is this the proper way to do it? if(isSet($_POST['playerFirst']['playerLast']['feet']['inches']['year']['status'])) { ## Something } else { ## Something else }
  11. Ok...figured out the (msg) part is table column and a function of the INSERT tag. (I thought "content" was the column. It's not.) Core functionality is working for me. Now I had to add the fields I need and make it able to match the coach's name.
  12. Question about this query: What does the (msg) do? How is it used? $content=$_POST['comment']; mysql_query("insert into players(msg) values ('$comment')"); $sql_in= mysql_query("SELECT msg,msg_id FROM players order by msg_id desc"); $r=mysql_fetch_array($sql_in); $msg=$r['msg']; $msg_id=$r['msg_id'];
  13. You guys posted those previous two response while I was responding to AyKay. Good stuff. I'll take a look at it and update here as I go along. I'm sure I'll need help.
  14. I do have some jQuery on my site (tabbed UI) that I manipulate a little. Is there something specific I should be looking for? Example, I know to go to the UI part to find UI solutions. Almost like their plugins. Is there something like that? Is there something called Live Update? THAT would be nice. : ) I hate to say it, my brain isn't good with starting from scratch to learn code. In HS (grad 1988), I could start decent programs from scratch in Fortran, but I went away from coding in college and didn't start to pick it back up until about 2003. I'm able to find the logic in a lot of what I see that applies to my problem and tweak it, but it's hard to learn from scratch when just about everything I do has to be while hitting the ground running. Luckily, most of these projects for me.
  15. I'm not looking for code, mostly just some direction, but I'm sure I'll be back as I try to shape the code. Also, I know very little about coding jQuery, Ajax, etc. Here is what I'm looking for: Basketball coach enters a Page that only he (or admin) can see. (I have that part figured out.) Once there, he has a form to fill out with a player's name and other information. I'd rather there not be 12 rows of empty cells. (Coaches will view that as work) I'd rather not have the Page reload on each "Add", but that would be the lesser of two evils. Is there a way to keep a persistent connection so when a coach hits Add, the player gets added to the database, a new empty form shows up, and the player's information shows up below on a roster?
  16. I have a data table inside my WP database that has coachFirst, coachLast, email, school as columns. I'm trying to create a page that acknowledges the User (that part works). From there it matches the first and last names in my data table then echos the school where they coach. It's the latter I can't get to work. Example, for me it looks like It show the name of the team I coach below that. It doesn't...of course. Here is the code/query I'm using: $current_user = wp_get_current_user(); $current_first = $current_user->user_firstname; $current_last = $current_user->user_lastname; echo 'Username: ' . $current_user->user_login . '<br />'; echo $current_first . ' ' . $current_last; $query = "SELECT * FROM schools WHERE coachFirst='$current_first' AND coachLast='$current_last'"; $result = mysql_query ($query); while ($result) { echo $result['school']; }
  17. I appreciate the link, but your code doesn't really help me. It just changes the output when I get an error vs. when the query produces nothing. In this instance it's likely both, and I'm really trying to work my way through Joins. What I've read on them doesn't give me much to go on, and that includes searching here and reading MySQL.
  18. Ooops...sorry. I had figured that out but didn't follow up. Thank you for your help.
  19. I am also trying to get help on the WordPress forums too.
  20. 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:
  21. 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'
  22. 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'
  23. 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)
  24. 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.
  25. As I said, I'm not really able to wrap my head around it.
×
×
  • 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.