Jump to content

I'd like my INSERT/UPDATE to show real time results on a Page...


Jim R

Recommended Posts

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?

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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'];

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.