jQuery/PHP Hide Div, Update Information from MySQL, Show Div New Information -


jquery:

$(document).ready(function(){      $(".reload").click(function() {         $("div#update").fadeout("fast")         .load("home.php div#update").fadein("fast")     }); }); 

php:

function statusupdate() {      $service_query = mysql_query("select * service order status");     $service_num = mysql_num_rows($service_query);      ($x=1;$x<=$service_num;$x++) {     $service_row = mysql_fetch_row($service_query);      $second_query = mysql_query("select * service sid='$service_row[0]'");     $row = mysql_fetch_row($second_query);      $socket = @fsockopen($row[3], $row[4], $errnum, $errstr, 0.01);      if ($errnum >= 1) { $status = 'offline'; } else { $status = 'online'; }      mysql_query("update service set status='$status' sid='$row[0]'")     or die(mysql_error());      ?>      <ul><li style="min-width:190px;"><?php echo $row[1]; ?></li>     <li style="min-width: 190px;" title="dns: <?php echo $row[2]; ?>">     <?php echo $row[3] . ':' . $row[4]; ?></li>     <li class="<?php echo $status; ?>" style="min-width:80px;"><div id="update">     <?php echo $status; ?></div></li></ul>       <?php      }  }  ?>  <?php statusupdate(); ?> 

i have button press (refresh) , refresh #update id fadeout results, , fade in new results... issue fades them out okay, when brings them back, it's div on div , div , looks messy - not it's meant (would have upload picture give further information).

in short, want happen when hit update, fade , fade in updated values php... made php/mysql function call when hit refresh button, thinking work, don't know how that...

thank-you in advance,

phillip.

javascript

 $(document).ready(function(){          $(".reload").click(function() {             $("div#update").fadeout("fast");             $.ajax({                  url:'home.php',                  data:{type:'getstatus'},                  type;'post',                   success:function(data){                     $('div#update').html(data).fadein('fast');                  }             });                });     }); 

php page format

<?php $type= $_post['type']; if($type=="getstatus") {     //get statuses data base , return formatted statuses in html } else {    //your page codes here    //like tags <html>,<body> etc, regular tags    //<script> tags etc } ?> 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -