i am trying to send the variables to server but url does not go to the php file.. What am i doing wrong? Is it because i am not using a submit button? Here is my code..
<table id="table">
<?php for($i=0; $i<$totalbesin; $i++) { ?>
<tr>
<td class="td" id="<?php echo "name".$i?>"><?php echo $besin[$i]['n']?></td>
<td class="td" id="<?php echo "kal".$i?>"><?php echo $besin[$i]['kal']?></td>
<td class="td" id="<?php echo "pro".$i?>"><?php echo $besin[$i]['pro']?></td>
<td class="td" id="<?php echo "kar".$i?>"><?php echo $besin[$i]['kar']?></td>
<td class="td" id="<?php echo "yag".$i?>"><?php echo $besin[$i]['yag']?></td>
<td class="ekle" id="yuk<?php echo $i?>">Ekle</td>
</tr>
<script type="text/javascript" >
$(function() {
$("#yuk<?php echo $i?>").click(function()
{
var name = $("#<?php echo "name".$i?>").val();
var kal = $("#<?php echo "kal".$i?>").val();
var pro = $("#<?php echo "pro".$i?>").val();
var kar = $("#<?php echo "kar".$i?>").val();
var yag = $("#<?php echo "yag".$i?>").val();
var dataString = '&name='+ name + '&kal=' + kal + '&pro=' + pro + '&kar=' + kar + '&yag=' + yag;
$.ajax({
type: "POST",
url: "dietup.php",
data: dataString,
cache: false,
success: function(html){
$("span#sonuc").text("<?php echo $i?>");
}
});
return false;
}); });
</script>
<?php } ?>
</table>
you need to change the val() to text(); like below as"td" tags not having an value tag
var name = $("#<?php echo "name".$i?>").text();
var kal = $("#<?php echo "kal".$i?>").text();
var pro = $("#<?php echo "pro".$i?>").text();
var kar = $("#<?php echo "kar".$i?>").text();
var yag = $("#<?php echo "yag".$i?>").text();
Take a look at ajaxForm & ajaxSubmit, otherwise you need a submit button.
http://malsup.com/jquery/form/
Try this
$.ajax({
type: "POST",
url: "dietup.php",
data: {
name: name,
kal: kal,
pro: pro
//and so on
},
cache: false,
success: function(html){
$("span#sonuc").text("<?php echo $i?>");
}
});
Use this to set the value into your variables:
var name = $("#name<?php echo$i?>").val();
var kal = $("#kal<?php echo $i?>").val();
var pro = $("#pro<?php echo $i?>").val();
var kar = $("#kar<?php echo $i?>").val();
var yag = $("#yag<?php echo $i?>").val();
In your code, as I understand, it seems that you are trying to assign values to your javscript variables using php.
There is a problem with syntax where you are assigning the values to your javscript variables.
Notice the following snippet from your code below:
var name = $("#<?php echo "name".$i?>").val();
var kal = $("#<?php echo "kal".$i?>").val();
var pro = $("#<?php echo "pro".$i?>").val();
var kar = $("#<?php echo "kar".$i?>").val();
var yag = $("#<?php echo "yag".$i?>").val();
Does anything seems not right?
Gotcha!!!! You are using double quotes to assign value in to your jquery selector and as well as for the php echo statement which is terminating your double quote.
Try using single quotes for the jquery selector and double quotes for the php echo statement as follows:
var name = $('#<?php echo "name".$i?>').val();
First of all, ajax parameter data must be object, not url string. If you want to send string url, add url string to url like this:
$.ajax({
url: "dietup.php?&name='+ name + '&kal=' + kal + '&pro=' + pro + '&kar=' + kar + '&yag=' + yag;"
})
But it will be wrong approach
I have divided yours script into two logical components.
First: is php loop generates the html table
Second: javascript function, who's sending ajax request
<table id="table">
<?php for($i=0; $i<$totalbesin; $i++) { ?>
<tr rel="<?php echo $i ?>">
<td class="td name" id="<?php echo "name".$i?>"><?php echo $besin[$i]['n']?></td>
<td class="td kal" id="<?php echo "kal".$i?>"><?php echo $besin[$i]['kal']?></td>
<td class="td pro" id="<?php echo "pro".$i?>"><?php echo $besin[$i]['pro']?></td>
<td class="td kar" id="<?php echo "kar".$i?>"><?php echo $besin[$i]['kar']?></td>
<td class="td yag" id="<?php echo "yag".$i?>"><?php echo $besin[$i]['yag']?></td>
<td class="ekle" id="yuk<?php echo $i?>">Ekle</td>
</tr>
<?php } ?>
</table>
<script type="text/javascript" >
$(function() {
$(".ekle").click(function()
{
var parent = $(this).closest('tr');
var data = {
name: parent.find('.name').val(),
kal: parent.find('.kal').val(),
pro: parent.find('.pro').val(),
kar: parent.find('.kar').val(),
yag: parent.find('.yag').val()
};
$.ajax({
type: "POST",
url: "dietup.php",
data: data,
cache: false,
success: function(html){
$("span#sonuc").text(parent.attr('rel'));
}
});
return false;
});
});
</script>
I found the problem.. It is because it does not get data from td, i tried getelementById but it did not work either.. Then i used
var name = '<?php echo $besin[$i]['n']?>';
and put the data in var like this.. Now it works.. Thank you for your time.. It would be better if i could get the data from td but its ok for now.. :)
I have a similar script, hope this help you:
<script type="text/javascript">
$(function() {
$("#yuk<?php echo $i?>").click(function(event)
{
var name = $("#<?php echo "name".$i?>").text();
var kal = $("#<?php echo "kal".$i?>").text();
var pro = $("#<?php echo "pro".$i?>").text();
var kar = $("#<?php echo "kar".$i?>").text();
var yag = $("#<?php echo "yag".$i?>").text();
var dataString = 'name='+ name + '&kal=' + kal + '&pro=' + pro + '&kar=' + kar + '&yag=' + yag;
//Uncomment to check the querystring
//alert("dietup.php?"+dataString);
$.ajax({
url:"dietup.php?"+dataString,
type:'GET',
dataType:'text',
cache:false,
success:function(data){
alert (data);
},
error:function(jxhr){
alert('Ops, error: '.jxhr.responseText);
}
}); //End Ajax
}); //End Click Function
}); //End Root Function
And here is the dietup.php example:
<?
//Get the parameters
$name = $_GET['name'];
//Do and return what you need
echo "your name is: ". $name;
?>
Related
I have the following php code:
<tr>
<td class="vacancyID">
<?php echo $vacancyID; ?>
</td>
<td class="roleLongTitle">
<?php echo $roleLongTitle; ?>
</td>
<td class="roleRequirements">
<?php echo $roleRequirements; ?>
</td>
<td class="roleResponsibilities">
<?php echo $roleResponsibilities; ?>
</td>
<td class="roleQualifications">
<?php echo $roleQualifications; ?>
</td>
<td class="closeDate">
<?php
//Convert the mySQL date to PHP date
echo convertToDate($closeDate);
?>
</td>
<td>
And the following jquery code:
$(document).ready(function(){
var btn = $('a.btn-primary');
var closeDate = $('td.closeDate');
var applyBtn = $('<input type="button" value=" Apply " class="toggleButton" />');
//var applyLnk = $('Apply');
//Rmove a link
btn.remove();
//Add button
applyBtn.insertAfter(closeDate);
//applyBtn.appendTo(closeDate);
//applyLnk.insertAfter(closeDate);
$('.toggleButton').click(function(){
var obj = $(this).closest('tr');
var data = {
vacancyID: obj.find('td.vacancyID').text(),
closeDate: obj.find('td.closeDate').text(),
roleLongTitle: obj.find('td.roleLongTitle').text(),
roleRequirements: obj.find('td.roleRequirements').text(),
roleResponsibilities: obj.find('td.roleResponsibilities').text(),
roleQualifications: obj.find('td.roleQualifications').text(),
}
//Post the data to the page
$.ajax({
type: 'POST',
url: 'vacancy.php',
data: data,
success: function(data){
window.location.assign("applyForVacancy.php");
}
});
//console.log(data);
});
});
Is there any way for me to make this better? I have tried many option and this one is the only one that's working and that can get access to those posted values based on the button I clicked.
i have products on my website and i made ajax call to insert product to shopping cart, but there is problem with clicking button. when i click on first product in list everything works but other product buttons do not react
<?php foreach ($products as $product):?>
<?php if($product['kateg'] == "men"):?>
<h5 style="color: #0669b4; min-height: 70px;"><?php echo $product['dasax']?></h5>
<p style="text-align: left; text-decoration: overline">Old price: <strong><span style="text-decoration: line-through"><?php echo round($product['fasi1'], 2)?> GEL</span></strong><br></p>
<p style="text-align: left">New Price: <strong><?php echo round($product['fasi2'], 2)?> GEL</strong><br></p>
<input type="hidden" value="<?php echo $product['id']?>" id="product_id">
<input type="hidden" value="<?php echo $product['dasax']?>" id="product_name">
<input type="hidden" value="<?php echo $product['fasi2']?>" id="product_price">
</a>
<button class="btn btn-primary" type="submit" id="add_to_cart">Add</button>
<?php endif;?>
<?php endforeach;?>
<script>
$(document).ready(function () {
$('#add_to_cart').click(function () {
var product_id = $("#product_id").val();
var product_name = $("#product_name").val();
var product_price = $("#product_price").val();
$.ajax({
url: "/uketesi/index",
method: "POST",
dataType: "json",
data: {
product_id:product_id,
product_name:product_name,
product_price:product_price,
},
success:function (data) {
alert("produqti warmatebit daemata")
$("#კალათა").html("<table id=\"example2\" class=\"table table-bordered table-hover\">" +
"<thead>" +
"<tr>" +
"<th>დასახელება</th>" +
"<th>ფასი</th>" +
"<th>იდენტიფიკატორი</th>" +
"</tr>" +
"<tr>" +
"<td>" + product_name + "</td>" +
"<td>" + product_price + "</td>" +
"<td>" + product_id + "</td>" +
"</tr>" +
"</thead>" +
"</table>");
}
});
});
});
</script>
I figured out how to solve the problem above, i have another question how can i add multiple products with this code. for now i only can add one product when i click on another product the old one dissepears.
You can get the data from data-*="" attribute on the button. So no need hidden inputs. For the click event you should use class name. Other case ID wont be unique. Please try following code.
<?php foreach ($products as $product):?>
<?php if($product['kateg'] == "men"):?>
<h5 style="color: #0669b4; min-height: 70px;"><?php echo $product['dasax']?></h5>
<p style="text-align: left; text-decoration: overline">Old price: <strong><span style="text-decoration: line-through"><?php echo round($product['fasi1'], 2)?> GEL</span></strong><br></p>
<p style="text-align: left">New Price: <strong><?php echo round($product['fasi2'], 2)?> GEL</strong><br></p>
</a>
<button class="btn btn-primary" type="submit" class="add_to_cart" data-id="<?php echo $product['id']?>" data-name="<?php echo $product['dasax']?>" data-price="<?php echo $product['fasi2']?>">Add</button>
<?php endif;?>
<?php endforeach;?>
<script>
$(document).ready(function () {
$('.add_to_cart').click(function () {
var product_id = $(this).data('id');
var product_name = $(this).data('name');
var product_price = $(this).data('price');
$.ajax({
url: "/uketesi/index",
method: "POST",
dataType: "json",
data: {
product_id:product_id,
product_name:product_name,
product_price:product_price,
},
success:function (data) {
}
});
});
});
</script>
Now that we have the form, and jQuery included in our document, we need to store it’s values in 2 variables, ( val1 and val2 ) so then we can pass it to the PHP file to process it.
$('#button').click(function() {
var val1 = $('#text1').val();
var val2 = $('#text2').val();
$.ajax({
type: 'POST',
url: 'process.php',
data: { text1: val1, text2: val2 },
success: function(response) {
$('#result').html(response);
}
});
});
As you can see in the code above, we create a .click event. This means that when the button with the ID of #button is click, out function will run. Then we get the value of each text field and store it in val1 and val2.
There is a div element :
...
<div id="liste_secteurs"></div>
...
<script type="text/javascript">
$(document).ready(function() {
rechercheSecteursEtProduits(0); // setting the div's content
$('#btnSupprimer').click(function() { // btnSupprimer = button generated from an ajax called inside previous function "rechercheSecteursEtProduits"
if ($(':checkbox[id^="prod_"]:checked').length > 0) {
var msg = "Do you want to remove these records ?";
if (confirm(msg)) {
$(':checkbox[id^="prod_"]:checked').each(function(){
var type = "",id="";
if($(this).val() == "") { // delete secteur
type = "secteur";
var tabIdx = $(this).attr("id").substr(5);
id = $("#secteur_"+tabIdx).val();
} else { // delete produit
type = "produit";
id = $(this).val();
}
$.ajax({
data: "type="+type+"&id="+id,
type: "POST",
url: "<?php echo HTTP_AJAX ?>service/SupprimerSecteursProduitsUserAjax.php", // deleting database row
async: false
});
});
rechercheSecteursEtProduits(0); // this causes the bug : the "delete" button does not work anymore after this code is called !
}
}
});
});
function rechercheSecteursEtProduits(pn){
var user = "<?php echo $_SESSION[CODE_USER]; ?>";
var html = $.ajax({
data: "id_user="+user,
type: "POST",
url: "<?php echo HTTP_AJAX ?>service/ListerProduitsUserParSecteursAjax.php?pn=" + pn,
async: false
}).responseText;
$('#liste_secteurs').html(html); // this is the div element
}
</script>
Code of ListerProduitsUserParSecteursAjax.php :
<?php
... // getting database data
?>
<p>Total : <?php echo $nr; ?></p>
<div><img src="<?php echo HTTP_ICON.'plus.png'; ?>" /></div>
<?php echo $paginationDisplay; ?>
<table id="table" class="data display " >
<thead style="background-color:#CCC">
<tr>
<th><?php echo _getText("service.produit.form.secteur_activite");?></th>
<th><?php echo _getText("service.produit.form.titre");?></th>
<th></th>
<th><?php if($data["secteur"]["cnt"] > 0){ ?><input type="checkbox" id="check_all"><?php }?></th>
</tr>
</thead>
<tbody style="background-color:#FFF">
<?php
if($data["secteur"]["cnt"] > 0){
for($i=0;$i<$data["secteur"]["cnt"];$i++){?>
<tr class="odd gradeX">
<td><?php echo $data["secteur"][$i]["secta_lib_fr"] ?></td>
<td><?php echo $data["secteur"][$i]["produit_lib"] ?></td>
<td align="center" style="vertical-align:middle"><img src="<?php echo HTTP_ICON.'edit.png'; ?>" alt="<?php echo _getText('main.btn.modifier'); ?>" style="height:10px;width:10px;" /></td>
<td align="center" style="vertical-align:middle"><input type="checkbox" id="prod_<?php echo $i; ?>" value="<?php echo $data['secteur'][$i]['id_user_produit']; ?>"><input type="hidden" id="secteur_<?php echo $i; ?>" value="<?php echo $data['secteur'][$i]['id_user_secteur']; ?>"></td>
</tr>
<?php } ?>
<?php
}
else{
?>
<tr class="odd gradeX">
<td colspan="4" align="center"><b><?php echo _getText('main.liste.no_data'); ?></b></td>
</tr>
<?php }?>
</tbody>
</table>
<?php if($data["secteur"]["cnt"] > 0){ ?>
<div align="right"><input name="btnSupprimer" id="btnSupprimer" type="button" value="<?php echo _getText("main.btn.delete"); ?>" class="btn btn-blue"/></div>
<?php } ?>
<?php echo $paginationDisplay; ?>
When the page loads for the first time then the delete button works fine : the selected rows are deleted , and the list reappears accordingly to new database data. But later when I want to delete other rows then the alert does not show when I check some checkboxes and clicking the delete button !
So what is wrong in my approach ?
From what I am reading you are having problems with the row that are added from the database.
What could be the problem is when you execute this peace of code:
$('#btnSupprimer').click(function() { // btnSupprimer = button generated from an ajax called inside previous function "rechercheSecteursEtProduits"
When you call the $.click() function you add a event to all the existing DOM object that have a id of 'btnSupprimer', however this doesn't update if you add a new DOM object. So what you should do is call this function every time you add a new row. you would get something like this:
function rechercheSecteursEtProduits(pn){
var user = "<?php echo $_SESSION[CODE_USER]; ?>";
var html = $.ajax({
data: "id_user="+user,
type: "POST",
url: "<?php echo HTTP_AJAX ?>service/ListerProduitsUserParSecteursAjax.php?pn=" + pn,
async: false
}).responseText;
$('#liste_secteurs').html(html);
$('#btnSupprimer').click(addClickHandler()); // this is the div element
}
function addClickHandler(){
if ($(':checkbox[id^="prod_"]:checked').length > 0) {
var msg = "Do you want to remove these records ?";
if (confirm(msg)) {
$(':checkbox[id^="prod_"]:checked').each(function(){
var type = "",id="";
if($(this).val() == "") { // delete secteur
type = "secteur";
var tabIdx = $(this).attr("id").substr(5);
id = $("#secteur_"+tabIdx).val();
} else { // delete produit
type = "produit";
id = $(this).val();
}
$.ajax({
data: "type="+type+"&id="+id,
type: "POST",
url: "<?php echo HTTP_AJAX ?>service/SupprimerSecteursProduitsUserAjax.php", // deleting database row
async: false
});
});
rechercheSecteursEtProduits(0); // this causes the bug : the "delete" button does not work anymore after this code is called !
}
}
}
I hope it helps
Try using on instead of click as below
$('#btnSupprimer').on("click","#liste_secteurs",function() { // btnSupprimer = button generated from an ajax called inside previous function "rechercheSecteursEtProduits"
if ($(':checkbox[id^="prod_"]:checked').length > 0) {
var msg = "Do you want to remove these records ?";
if (confirm(msg)) {
$(':checkbox[id^="prod_"]:checked').each(function(){
var type = "",id="";
if($(this).val() == "") { // delete secteur
type = "secteur";
var tabIdx = $(this).attr("id").substr(5);
id = $("#secteur_"+tabIdx).val();
} else { // delete produit
type = "produit";
id = $(this).val();
}
$.ajax({
data: "type="+type+"&id="+id,
type: "POST",
url: "<?php echo HTTP_AJAX ?>service/SupprimerSecteursProduitsUserAjax.php", // deleting database row
async: false
});
});
rechercheSecteursEtProduits(0); // this causes the bug : the "delete" button does not work anymore after this code is called !
}
}
});
Use the dynamic jquery selector instead of the regular 'click' event
$('#liste_secteurs').on('click', '#btnSupprimer', function() {});
// $("container").on("event", "button", function() {});
As from Caveman's answer I made some updates :
function rechercheSecteursEtProduits(pn) {
var user = "<?php echo $_SESSION[CODE_USER]; ?>";
var html = $.ajax({
data: "id_usermer="+user,
type: "POST",
url: "<?php echo HTTP_AJAX ?>service/ListerProduitsUserParSecteursAjax.php?pn=" + pn,
async: false
}).responseText;
$('#liste_secteurs').html(html);
$('#btnSupprimer').on('click',function(){
if ($(':checkbox[id^="prod_"]:checked').length > 0) {
if (confirm("Do you want to remove these records ?")) {
$(':checkbox[id^="prod_"]:checked').each(function(){
var type = "",id="";
if($(this).val() == "") { // delete secteur
type = "secteur";
var tabIdx = $(this).attr("id").substr(5);
id = $("#secteur_"+tabIdx).val();
} else { // delete produit
type = "produit";
id = $(this).val();
}
$.ajax({
data: "type="+type+"&id="+id,
type: "POST",
url: "<?php echo HTTP_AJAX ?>service/SupprimerSecteursProduitsUserAjax.php", // deleting database row
async: false
});
});
rechercheSecteursEtProduits(0);
}
}
});
}
And it works !
I have an HTML table generated by PHP querying from MySQL table.
<table>
<tr>
<th>Sl</th>
<th>ID</th>
<th>Article Name</th>
<th>Publish Status</th>
</tr>
<?php
$i = 1;
foreach ($obj->showAllFromTable('pattern') as $pattern) {
extract($pattern);
?>
<tr>
<td><?php echo $i++; ?></td>
<td><?php echo $id; ?></td>
<td><?php echo $pattern_name; ?></td>
<td id="publish_<?php echo $id; ?>" class="status_pattern">
<?php echo $publish; ?>
</td>
</tr>
<?php
}
?>
</table>
I want to change the status of any article by clicking on the 'publish' cell of the corresponding article row. I am trying to use ajax method of jquery for this purpose as shown in the following:
<script type="text/javascript">
$(document).ready(function(){
$('.status_pattern').click(function(){
var thisid = $(this).attr('id');
$.ajax({
url: "status_change_pattern.php",
data: {
id: thisid
},
success: function (response) {
alert(response);
}
});
});
});
</script>
In the "success" block, instead of "alert", I want to create a functionality to change the text of the specific cell which I clicked. The "status_change_pattern.php" has just a text "Hey Hey".
Can anyone help? Please.
Thanks.
You have to use closure to preserve the id.
<script type="text/javascript">
$(document).ready(function(){
$('.status_pattern').click(function(){
var thisid = $(this).attr('id');
$.ajax({
url: "status_change_pattern.php",
data: {
id: thisid
},
success: function (id) {
return function (response) {
$("#" + id).html(response);
}
}(thisid)
});
});
});
</script>
You need to write,
success: function (response) {
$(thisid).html(response);
}
Here in response, you need to get new status.
The solution provided by SajithNair works. Thanks to SajithNair. But it can also be done without using closure. As shown below:
$('.status_pattern').click(function() {
var thisid = $(this).attr('id');
$.ajax({
url : "status_change_pattern.php",
data : {
id : thisid
},
success : function(response) {
$('#' + thisid).html(response);
}
});
});
Thanks
I am trying to delete a value in a comma seperated string in a table. The script that does this (delete_url.php) works fine on it's own if I set the post values manually, but I'm having a problem passing those values to the script with ajax. In the page that I want to pass the values from I have:
<script type="text/javascript">
$(document).ready(function() {
$('.delete').click(function() {
$.ajax({
type: 'POST',
url: '../scripts/delete_link.php',
data: 'link=' + $(this).attr('data_link') + '&topic_pk=' + $(this).attr('data_topic'),
success: function() {
}
});
});
});
</script>
And:
<a class='delete_link' href='#' data_link='<?php echo urlencode($link); ?>' data_topic='<?php echo $topic_pk; ?>' onclick="return confirm('Are you certain you want to DELETE this link?')";><img src="../images/delete.png" width="16" height="16" alt="delete" title="delete this link" border='0' /></a>
I probably should be using json, but not sure of the correct way to do this. Thanks for any help.
I have updated my code with the folowing and now works deleting the record and removing the entry on the page:
<script type="text/javascript">
$(document).ready(function(){
$('table#delTable td a.delete_link').click(function()
{
if (confirm("Are you sure you want to delete this row?"))
{
var id = $(this).parent().parent().attr('id');
var data = 'id=' + id ;
var parent = $(this).parent().parent();
$.ajax(
{
type: "POST",
url: '../scripts/delete_link.php',
data: 'link=' + $(this).attr('data_link') + '&topic_pk=' + $(this).attr('data_topic') + '&topic_introduction=' + $(this).attr('data_introduction'),
cache: false,
success: function()
{
parent.fadeOut('fast', function() {$(this).remove();});
}
});
}
});
});
</script>
And the table:
<table id='delTable' width="100%" border="0" cellpadding="5">
<?php
if(!empty($retrieved_links)){
foreach($retrieved_links as $link){
?>
<tr>
<td><?php echo $link; ?></td>
<td width='16' align='center' valign='middle'><a class='delete_link' href='#' data_link='<?php echo urlencode($link); ?>' data_topic='<?php echo $topic_pk; ?>' data_introduction='<?php echo $topic_introduction; ?>'><img src="../images/delete.png" width="16" height="16" alt="delete" title="delete this link" border='0' /></a></td>
</tr>
<?php }
}
?>
</table>
And delete_link.php:
<?php
require_once('../connection/connect.php');
mysql_select_db($database, $connection);
$link = urldecode($_POST['link']);
$topic_pk = $_POST['topic_pk'];
$topic_introduction = $_POST['topic_introduction'];
if(!empty($link)){
$query_get_topic = "SELECT * FROM topic WHERE topic_pk = '$topic_pk'";
$result_get_topic = mysql_query($query_get_topic, $connection) or die(mysql_error());
$row_get_topic = mysql_fetch_assoc($result_get_topic);
$retrieved_links = explode(",", $row_get_topic['links']);
$delete_link = array_search($link,$retrieved_links);
unset($retrieved_links[$delete_link]);
$updated_links = mysql_real_escape_string(implode(',',$retrieved_links));
$links_body = str_replace(',', '<p>', $updated_links);
$topic = $topic_introduction . '<p>' . $links_body;
$query = "UPDATE topic SET links = '$updated_links', topic = '$topic' WHERE topic_pk = '$topic_pk'";
$result = mysql_query($query, $connection) or die(mysql_error());
}
mysql_close();
?>