Yea, i want it to dynamically load without having to reload the page. I'll read into retrieving data with AJAX, then I'll look into AJAX with PHP. I read my JS book last night which has a whole chapter dedicated to AJAX. I know the basic syntax to setup the data retrieval, but it's just working with the AJAX and PHP which I know absolutely nothing about.
Also, because I want the data to display dynamically, do I display the results with PHP first, then use the AJAX to change it? Or do I have to dynamically load the PHP with AJAX first, then change again with AJAX?
Here is the code I have at the moment:
PHP Code:
<div id="content">
<div id="order_links_div">
<a href="sort.php?o=asc">ASC</a>|<a href="sort.php?o=desc">DESC</a>
</div>
<table id="members_table" name="members_table">
<tr>
<th>Member No.</th>
<th>Username</th>
<th>Join Date</th>
</tr>
<?php
require ("connectdb.php");
$sql = mysql_query("SELECT * FROM members");
if(!$sql){
echo "There was an error retrieving the data.";
exit(0);
}
while($row = mysql_fetch_array($sql)){
echo "<tr><td>".$row['id']."</td><td>".$row['username']."</td><td>".$row['join_date']."</td></tr>";
}
?>
</table>
</div>
I'm guessing this is not the right way because I don't think this will change the data around because it is coded to display anything retrieved from the database in that order.....
My question is, do I have to load the database results as soon as the 'members.php' page loads using PHP, or do I use AJAX from the start?
Hope you can understand my issue.
Thanks for all your replies.
Regards,
LC.