Jim R Posted August 30, 2011 Share Posted August 30, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/246034-id-like-my-insertupdate-to-show-real-time-results-on-a-page/ Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 you will want AJAX.. will need to learn.. I suggest using jquery's AJAX API.. very easy to learn and powerful.. Quote Link to comment https://forums.phpfreaks.com/topic/246034-id-like-my-insertupdate-to-show-real-time-results-on-a-page/#findComment-1263530 Share on other sites More sharing options...
cunoodle2 Posted August 30, 2011 Share Posted August 30, 2011 I went to that google page and searched for.. using ajax to do live updates to a mysql One of the best results was this one.. http://www.9lessons.info/2009/11/insert-delete-with-jquery-and-ajax.html Give it a try.. post some code and let us know what you come up with. Quote Link to comment https://forums.phpfreaks.com/topic/246034-id-like-my-insertupdate-to-show-real-time-results-on-a-page/#findComment-1263531 Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 I went to that google page and searched for.. using ajax to do live updates to a mysql One of the best results was this one.. http://www.9lessons.info/2009/11/insert-delete-with-jquery-and-ajax.html Give it a try.. post some code and let us know what you come up with. ganced over the link.. looks to be a decent tut... OP if you have questions let us know Quote Link to comment https://forums.phpfreaks.com/topic/246034-id-like-my-insertupdate-to-show-real-time-results-on-a-page/#findComment-1263533 Share on other sites More sharing options...
Jim R Posted August 30, 2011 Author Share Posted August 30, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/246034-id-like-my-insertupdate-to-show-real-time-results-on-a-page/#findComment-1263536 Share on other sites More sharing options...
Jim R Posted August 30, 2011 Author Share Posted August 30, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/246034-id-like-my-insertupdate-to-show-real-time-results-on-a-page/#findComment-1263538 Share on other sites More sharing options...
Jim R Posted August 30, 2011 Author Share Posted August 30, 2011 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']; Quote Link to comment https://forums.phpfreaks.com/topic/246034-id-like-my-insertupdate-to-show-real-time-results-on-a-page/#findComment-1263687 Share on other sites More sharing options...
Jim R Posted August 30, 2011 Author Share Posted August 30, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/246034-id-like-my-insertupdate-to-show-real-time-results-on-a-page/#findComment-1263692 Share on other sites More sharing options...
AyKay47 Posted August 31, 2011 Share Posted August 31, 2011 "msg" should be replaced with whatever the field name is in your table Quote Link to comment https://forums.phpfreaks.com/topic/246034-id-like-my-insertupdate-to-show-real-time-results-on-a-page/#findComment-1263868 Share on other sites More sharing options...
Jim R Posted September 1, 2011 Author Share Posted September 1, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/246034-id-like-my-insertupdate-to-show-real-time-results-on-a-page/#findComment-1264430 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.