JQuery - Update Table
6 answers
This assumes that your PHP is returning inline-ready HTML for the table:
$("#update_button").click(function(){
$("#mytable").load("/tools/getTable.php")
})
on your page you need a DIV placeholder:
<div id="mytable"></div>
and your getTable.php should echo the html back like this:
<table>
<tr>
<td>col1<td>
<td>col2<td>
<tr>
</table>
+4
a source to share
As a point:
- Send user data to PHP page via AJAX request. (Look at the jQuery Form plugin)
- A PHP page should accept and validate data, insert it into the database, and then send a response to the page in some format (I recommend JSON using the php json_encode .
- The response should be either "rejected" or "accepted" with the user data returned, cleaned to suit the requirements of your own system.
- Then, in the AJAX success callback method, use jQuery to add the data to the table, or give them a message telling them why it was rejected.
+1
a source to share
When the user clicks the button, you must invoke the code that was used to load the table. Data can be data from the beginning + data added by users. Or the data can be reassigned from the server, depending on how your application works.
A little more information may clarify the situation, so we could provide more specific answers.
0
a source to share
Well, the table is created using this:
<table id="bookmarks">
<thead>
<tr class="table-top">
<th>Thumbnail</th>
<th>Title/Description</th>
<th>Tags</th>
<th>Action</th>
</tr>
</thead>
<?php
$hID = userToID($_SESSION['username']);
$hQuery = mysql_query("SELECT * FROM linkz WHERE userid='$hID'") or die(mysql_error());
while($hRow = mysql_fetch_array($hQuery)) {
echo "<tr class='link'><td><img src='http://www.thumbshots.de/cgi-bin/show.cgi?url=".$hRow["location"]."' /></td><td><a href='share/".$hRow['shareid']."'>".$hRow["title"]."</a> - <i>". $hRow["description"]."</i><br /><b>Share Link:</b> http://www.linkbase.us/share/".$hRow['shareid']."</td><td>".$hRow['tags']."</td><td><a href='#' id='".$hRow['shareid']."' class='delbutton'>Delete</a></td></tr>";
}
?>
</table>
0
a source to share