I’m working on this project trying to create a simple site where a user can input information then on a different page that same information is displayed.
I am using JQuery to refresh the page and .load new content, MySQL to store the information, and PHP to insert and retrieve that information.
The problem I am having now is i’m using Javascript to update the page and .fadeIn the data but currently it is just fading out and fading in ALL of the data. What I want it to do is to keep the current data the same and ONLY fade in the new data.
Here is my JQuery function:
<script type="text/javascript">
$(document).ready(function() {
var refreshId = setInterval(function() {
$("#responsecontainer").fadeOut('fast').load('output.php');
}, 3000);
$.ajaxSetup({ cache: false });
});
</script>
Here is my PHP called ‘output.php’:
<?php include_once('db_connect.php'); ?>
<?php include_once('input.php'); ?>
<?php
//query the database
$query = mysql_query("SELECT * FROM notes ORDER BY ID DESC");
//fetch the results / convert results into an array
while($rows = mysql_fetch_array($query)):
$title = $rows['notestitle'];
$text = $rows['notestext'];
?>
<div id="title">
<h1><?php echo "$title<br>"; ?></h1>
</div>
<div id="text">
<h2><?php echo "$text<br>"; ?></h2>
</div>
<?php endwhile; ?>
And here is the code for the page that is displaying the info:
<?php include_once('db_connect.php'); ?>
<?php include_once('input.php'); ?>
<div id="header"></div>
<div id="responsecontainer">
<?php include_once('output.php'); ?>
</div>
Let me know if you need me to provide anything else or if something is unclear to you.
Thanks for your time.
Use this simple query with limit