Solved

Refresh MySQL data in table without refreshing entire page

Posted on 2009-04-01
2
2,609 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
2 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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:
RQuadling earned 500 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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 count occurrences of each item in an array.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now