Jump to content

Jim R

Members
  • Posts

    988
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Jim R

  1. mysql_affected_rows doesn't work. : ) Is there another function that will accomplish what I want, or do I have a separate query?
  2. Oh...I tried a number of ways to output what's just below it in DIV roster_team_info, including just using the $result variable. I did wonder about that, thinking of the description of that fetch, that it moves the pointer ahead. How do I go about getting my result? Separate query or something like affected rows? The information in that DIV just comes from the schools data table. Oddly enough, that might answer my question in another post.
  3. No. That's just there to show Returning Starters is value 1.
  4. I'm not even sure how to explain it. I'm linking a team's roster to its coach. Now I'm getting a weird offset issue when I output the roster. It has something to do with the STATUS. Down below DIV class="roster_player_list", my Status values are 1, 2, 3, or 4, and each is then assigned a word value. My output should look like this (without the arrow and number) : Returning Starter <---- 1 # # # Key Returner <--- 2 # # Varsity Newcomer <--- 3 # # # Key Freshmen <--- 4 # The last "1" (Returning Starter) disappears from my list on both of my test accounts. I should have four Returning Starters instead of three. I've changed a player's status from a 2 to a 1, and the list changed. That player disappeared, the other appeared. $sql = "SELECT * FROM players as p INNER JOIN schools as s WHERE s.coachFirst='".$current_first."' AND s.coachLast='".$current_last."' AND s.id = p.tid ORDER BY status, playerLast"; $results = mysql_query($sql); echo '<div class="roster">'; $team = mysql_fetch_assoc($results); echo '<div class="roster_team_info">' . $current_first . ' ' . $current_last . ' <div class="school">' . $team['school'] . '</div> <div class="coach">Coach ' .$team['coachFirst'] . ' ' . $team['coachLast'] .'</div> <div>Sectional: ' . $team['sectional'] . '</div> <div>Class: ' . $team['class'] . 'A</div> '; echo '</div>'; echo '<div class="roster_player_list">'; $currentStatus = false; //Flag to detect change in status while($player = mysql_fetch_assoc($results)) { if($currentStatus != $player['status']) { //Status has changed, display status header $currentStatus = $player['status']; echo '<br><b>'; if ($currentStatus == '1') {echo 'Returning Starters';} elseif ($currentStatus == '2') {echo 'Key Returners';} elseif ($currentStatus == '3') {echo 'Varsity Newcomers';} elseif ($currentStatus == '4') {echo 'Key Freshmen';} echo '</b><br>'; } //Display player info echo $player['playerFirst'] . ' ' . $player['playerLast'] . ', ' . $player['feet'] . '\'' . $player['inches'] . '",' . $player['position'] . ', ' . $player['year'] . ';<br>'; }
  5. Awesome. Thanks. I have another one down there, dealing with the same code, different issue.
  6. Basically what I'm getting with that is the WHILE loop picks up there is no match, but the IF doesn't. So it's not showing the contact_form DIV, but it is show the roster DIV. It's probably something grossly simple that I'm missing or just basically goes over my head.
  7. Man, I'm having a rough week with questions--if you're following at home. Basically matching a Coach's first and last name to another table, which if matched will yield information about that coach's team. // or get user by username $current_user = wp_get_current_user(); $current_first = $current_user->user_firstname; $current_last = $current_user->user_lastname; $current_id = $current_user->ID; echo '<div class="contact_form">'; echo $current_first . ' ' . $current_last .' :: '; $query = "SELECT * FROM schools WHERE coachFirst='".$current_first."' AND coachLast='".$current_last."'"; $result = mysql_query ($query); if(!$result) { echo 'There is not a match for your name.'; } else { while($school= mysql_fetch_array($result)) { echo $school['school'] . ' ' . $school['id']; include(ABSPATH ."wp-content/plugins/my-team/form.php"); } echo '</div>'; echo '<div class="roster">'; include(ABSPATH ."wp-content/plugins/my-team/roster.php"); echo '</div>'; }
  8. The whole code is below, followed by the part that isn't producing. It all works extremely well until the last part, and I have two instances of setting a variable to mysql_fetch_assoc that work. Not sure why the third attempt doesn't. I'm just trying to have a separate area that outputs 'msg'. $sql = "SELECT * FROM players as p INNER JOIN schools as s WHERE p.tid = s.id ORDER BY status, playerLast"; $results = mysql_query($sql); echo '<div class="roster">'; $team = mysql_fetch_assoc($results); echo '<div class="team_info"> <div class="school">' . $team['school'] . '</div> <div class="coach">Coach ' .$team['coachFirst'] . ' ' . $team['coachLast'] .'</div> <div>Sectional: ' . $team['sectional'] . '</div> <div>Class: ' . $team['class'] . 'A</div> '; echo '</div>'; $currentStatus = false; //Flag to detect change in status while($player = mysql_fetch_assoc($results)) { if($currentStatus != $player['status']) { //Status has changed, display status header $currentStatus = $player['status']; echo '<br><b>'; if ($currentStatus == '1') {echo 'Returning Starters';} elseif ($currentStatus == '2') {echo 'Key Returners';} elseif ($currentStatus == '3') {echo 'Varsity Newcomers';} elseif ($currentStatus == '4') {echo 'Key Freshmen';} echo '</b><br>'; // echo "<div><b>{$currentStatus}</b></div>\n"; } //Display player info echo $player['playerFirst'] . ' ' . $player['playerLast'] . ', ' . $player['feet'] . '\'' . $player['inches'] . '",' . $player['position'] . ', ' . $player['year'] . ';<br>'; } //Player comments echo '<hr>'; echo '<div class="coach_comments"><span class="player_name">hello'; while($comments = mysql_fetch_assoc($results)) { echo $comments['playerFisrt'] . ' ' . $comments['playerLast'] . ': </span>' . $comments['msg']; } echo '</div>'; echo '</div>'; It's all working until what's below. All I get out of it is the "hello", which is just a test to make sure it wasn't a CSS issue.
  9. @mjdamato, should have used $player instead of $key when outputting the player information. It works really well. Thank you.
  10. @mjdamato What you produced works pretty well. It doesn't output the player information though. The structure shows up, as best as I can tell exactly how I want it. @voip03 Do you mean to determine the structure? Certainly you can to determine how it actually looks, whether you want to use a table or list format. In this instance, I just need a list.
  11. Sorry, sort of took it for granted. Table "schools", just matches the User, which is a coach, to his team/players. All the information being output is from "players", one status per player. $sql = "SELECT * FROM players as p INNER JOIN schools as s WHERE p.tid = s.id ORDER BY status, playerLast"; $results = mysql_query($sql);
  12. I'm trying to output this: Status Player Player Player Status Player Player Player Status Player Player I tried this, but it didn't work: while($players = mysql_fetch_assoc($results)) { foreach ($players as $player=>$status){ echo '<div>' . $player['status'] . '</div>'; foreach ($status as $key) { echo $key['playerFirst'] . ' ' . $key['playerLast'] . ', '. $key['year'] . '<br>'; } } } I guess I'm trying to find a more efficient way of doing this rather than if/elseif for each one. Right now, there are only four groupings, but in the future there could be as many 406.
  13. I don't work with JS at all--php a lot though--but I'm hoping some small input can help me see the logic in it. This is part of another problem I had, which has led me to the JS portion of it. The below code allows the User to submit a message and have it show up on the screen in real time, without a refresh. The middle part of it is interaction with a database. Here is the demo: http://demos.9lessons.info/update_delete.php My issue is I have a form where I'd like it to include the person's first and last name (actually more than that). In searching for the answer here and the internet in general, I find examples of form submission, serialized data, etc, but nothing that I can make enough sense to fit it into the below code. My main interest is the real time nature of it. Otherwise, I can easily set up my form to Insert, present a new form, and show an updated list to the User via a refresh after submitting data. Basically, it's coaches creating a roster online. How do I go about adding the fields I need to include? <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>
  14. I've sort of backed my way into this question on two topics now. My other problem has led me to consider the javascript linked above. I got it to work on my site, but in trying to expand it, it just shows the one field. Here is the code in the link above: <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> I have that in the same file as the form. Would the JS have any effect on what is being passed from the form to the file that processes the data and Inserts into the database? It only passes the Content field to my database. What would I need to change?
  15. Maybe I should clarify. The JS is on the file with the form. From the form to the update_data.php, it appears to only be passing along the Content field. Would the JS have any effect on that?
  16. 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>
  17. Status is my last field. Where should a comma go?
  18. 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.
  19. 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); } }
  20. That was my next question above. Basically I just use If statements for each required field?
  21. 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.
  22. 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.
  23. "empty" I get. Would I use if...elseif...elseif...etc to cover each entry?
  24. 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?
  25. 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 }
×
×
  • 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.