Solved

Refresh MySQL data in table without refreshing entire page

Posted on 2009-04-01
2
2,614 Views
Last Modified: 2013-12-12
I have the following code that creates a table based upon several MySQL queries.  I need the queries to refresh every 30 sec without refreshing the entire table.  I am told that this is possible with Javascript or AJAX, but I don't know enough to do this.  Any help would be appreciated
<?php session_start();
require_once('Connections/connect_crm.php'); 
mysql_select_db($database_connect_crm, $connect_crm);
$user = $_SESSION['svusername'];
//$user = "money1";
 
$query_rs_select11 = "SELECT * FROM download WHERE downloaded = 0 AND source = 'cbacks' ";
//$query_rs_select = sprintf("SELECT * FROM cbacks WHERE mid_user = '$user' ");
$rs_select11 = mysql_query($query_rs_select11, $connect_crm) or die(mysql_error());
$row_rs_select11 = mysql_fetch_assoc($rs_select11);
$totalRows_rs_select11 = mysql_num_rows($rs_select11);
 if(!mysql_num_rows($rs_select11)) {
 
$down = 0;
 
} else {
$down = $totalRows_rs_select11;
  
 
}
 
 
$query_rs_select12 = "SELECT * FROM download WHERE downloaded = 0 AND source = 'rets' ";
//$query_rs_select = sprintf("SELECT * FROM cbacks WHERE mid_user = '$user' ");
$rs_select12 = mysql_query($query_rs_select12, $connect_crm) or die(mysql_error());
$row_rs_select12 = mysql_fetch_assoc($rs_select12);
$totalRows_rs_select12 = mysql_num_rows($rs_select12);
 if(!mysql_num_rows($rs_select12)) {
 
$downa = 0;
 
} else {
$downa = $totalRows_rs_select12;
  
 
}
 
$query_rs_select1 = "SELECT * FROM cbacks WHERE assessor_done = 1 AND reject = 0 AND approval = 0 ";
//$query_rs_select = sprintf("SELECT * FROM cbacks WHERE mid_user = '$user' ");
$rs_select1 = mysql_query($query_rs_select1, $connect_crm) or die(mysql_error());
$row_rs_select1 = mysql_fetch_assoc($rs_select1);
$totalRows_rs_select1 = mysql_num_rows($rs_select1);
 if(!mysql_num_rows($rs_select1)) {
 
$review = 0;
 
} else {
$review = $totalRows_rs_select1;
  
 
}
 
$query_rs_select2 = "SELECT * FROM rets  WHERE assessor_done = 1 AND reject = 0 AND approval = 0 ";
//$query_rs_select = sprintf("SELECT * FROM cbacks WHERE mid_user = '$user' ");
$rs_select2 = mysql_query($query_rs_select2, $connect_crm) or die(mysql_error());
$row_rs_select2 = mysql_fetch_assoc($rs_select2);
$totalRows_rs_select2 = mysql_num_rows($rs_select2);
 if(!mysql_num_rows($rs_select2)) {
 
$reviewa = 0;
 
} else {
$reviewa = $totalRows_rs_select2;
  
 
}
 
 
$query_rs_select = "SELECT * FROM cbacks WHERE assessor_done = 0   ";
//$query_rs_select = sprintf("SELECT * FROM cbacks WHERE mid_user = '$user' ");
$rs_select = mysql_query($query_rs_select, $connect_crm) or die(mysql_error());
$row_rs_select = mysql_fetch_assoc($rs_select);
$totalRows_rs_select = mysql_num_rows($rs_select);
 if(!mysql_num_rows($rs_select)) {
 
$upload = 0;
 
} else {
$upload = $totalRows_rs_select;
  
 
}
$query_rs_selecta = "SELECT * FROM rets  WHERE assessor_done = 0   ";
//$query_rs_select = sprintf("SELECT * FROM cbacks WHERE mid_user = '$user' ");
$rs_selecta = mysql_query($query_rs_selecta, $connect_crm) or die(mysql_error());
$row_rs_selecta = mysql_fetch_assoc($rs_selecta);
$totalRows_rs_selecta = mysql_num_rows($rs_selecta);
 if(!mysql_num_rows($rs_selecta)) {
 
$uploada = 0;
 
} else {
$uploada = $totalRows_rs_selecta;
  
 
}
 
 
 
$query_rs_select9 = "SELECT * FROM cbacks WHERE reject = 1   AND deleteMe != '99'";
//$query_rs_select = sprintf("SELECT * FROM cbacks WHERE mid_user = '$user' ");
$rs_select9 = mysql_query($query_rs_select9, $connect_crm) or die(mysql_error());
$row_rs_select9 = mysql_fetch_assoc($rs_select9);
$totalRows_rs_select9 = mysql_num_rows($rs_select9);
 if(!mysql_num_rows($rs_select9)) {
 
$reject = 0;
 
} else {
$reject = $totalRows_rs_select9;
  
 
}
$query_rs_select8 = "SELECT * FROM rets  WHERE reject = 1   ";
//$query_rs_select = sprintf("SELECT * FROM cbacks WHERE mid_user = '$user' ");
$rs_select8 = mysql_query($query_rs_select8, $connect_crm) or die(mysql_error());
$row_rs_select8 = mysql_fetch_assoc($rs_select8);
$totalRows_rs_select8 = mysql_num_rows($rs_select8);
 if(!mysql_num_rows($rs_select8)) {
 
$rejecta = 0;
 
} else {
$rejecta = $totalRows_rs_select8;
  
 
}
$query_rs_select7 = "SELECT * FROM cbacks WHERE approval = 1  ";
//$query_rs_select = sprintf("SELECT * FROM cbacks WHERE mid_user = '$user' ");
$rs_select7 = mysql_query($query_rs_select7, $connect_crm) or die(mysql_error());
$row_rs_select7 = mysql_fetch_assoc($rs_select7);
$totalRows_rs_select7 = mysql_num_rows($rs_select7);
 if(!mysql_num_rows($rs_select7)) {
 
$fax = 0;
 
} else {
$fax = $totalRows_rs_select7;
  
 
}
$query_rs_select6 = "SELECT * FROM rets  WHERE approval = 1   ";
//$query_rs_select = sprintf("SELECT * FROM cbacks WHERE mid_user = '$user' ");
$rs_select6 = mysql_query($query_rs_select6, $connect_crm) or die(mysql_error());
$row_rs_select6 = mysql_fetch_assoc($rs_select6);
$totalRows_rs_select6 = mysql_num_rows($rs_select6);
 if(!mysql_num_rows($rs_select6)) {
 
$faxa = 0;
 
} else {
$faxa = $totalRows_rs_select6;
  
 
}
 
$lost = 0;
$losta = 0;
 
 
?>
 
 
 
 
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="refresh" content="600" > 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Transpoint 360</title>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
 
<body>
<table width="873" border="0" align="center">
  <tr>
    <td width="261"><table width="259" height="98" border="0">
      <tr>
        <td><div align="center">You Are Logged In As
          <p><?php echo $_SESSION['svfirstname']; ?> <?php echo $_SESSION['svlastname']; ?> </p>
        </div></td>
      </tr>
    </table></td>
    <td width="261"><img src="images/Transpoint.gif" alt="" width="261" height="67" /></td>
    <td width="337"><div align="center">
      <h3>Welcome to Transpoint 360's Chargebacks and Retrievals  Processing System</h3>
    </div></td>
  </tr>
  <tr>
    <td colspan="3"><div align="center"><strong>As you enter, edit or delete data in this system, the database will also record that you were the one making the changes. So be accurate as you enter or edit information in this system!</strong></div></td>
  </tr>
  <tr>
    <td colspan="3">ADMIN TESTING SITE!!!!!</td>
  </tr>
  <tr>
    <td colspan="3"><table width="871" border="1">
      <tr>
        <td width="431"><div align="center">Current Work Status</div></td>
        <td width="200"><div align="center">Chargebacks</div></td>
        <td width="226"><div align="center">Retrievals</div></td>
      </tr>
      <tr>
        <td>Entered, but need additional work</td>
        <td><div align="center"><?php echo $upload; ?></div></td>
        <td><div align="center"><?php echo $uploada; ?></div></td>
      </tr>
      <tr>
        <td>Sent Back from Manager, Need Additional Work</td>
        <td><div align="center"><?php echo $reject; ?></div></td>
        <td><div align="center"><?php echo $rejecta; ?></div></td>
      </tr>
      <tr>
        <td>Ready to be reviewed for fax approval</td>
        <td><div align="center"><?php echo $review; ?></div></td>
        <td><div align="center"><?php echo $reviewa; ?></div></td>
      </tr>
      <tr>
        <td>Ready to be DOWNLOADED</td>
        <td><div align="center"><?php //echo $fax;
		echo $down; ?></div></td>
        <td><div align="center"><?php echo $downa; ?></div></td>
      </tr>
    </table>

Open in new window

0
Comment
Question by:fastfind1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 24050024
Why not try using an iframe?  Then you can just have the meta refresh tag fire a new inner page every 30 seconds.  Easy!
0
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 500 total points
ID: 24054337
I use the Prototype JS library for my AJAX processing (http://prototypejs.org).

The Ajax.PeriodicUpdater facility is probably the perfect fit.

http://www.prototypejs.org/learn/introduction-to-ajax and look down to "Automate requests with the Ajax.PeriodicalUpdater"
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question