Jump to content

Need help with Updating Database


b

Recommended Posts

Hi, I'm using TableKit to display, sort, and inline edit my table of data.  When I edit the data in the table, it calls an update.php page that should update my database.  But I can't figure out how to write this script.  I will show you what I'm trying to work with as of now:

 

<?php

// Include connection to your database
$con = mysql_connect("localhost","###","###");
mysql_select_db("myrunningpb", $con) or die(mysql_error());

$update_query = "UPDATE myrunningpb SET fifteen = '$fifteen'  WHERE id='$id'";

echo $_POST['value'];
?>

 

After making the connection to the database, how do I update the database with the new edited information in my table?  Here is an example of a portion of my table:

 

echo "<div id='head'>";
echo "<ul>";
echo "<li>" . $list['first'] . "</li>";
echo "<br/>";
echo "<li>" . $list['last'] . "</li>";
echo "<br/>";
echo "<li>" . $list['age'] .  "</li>";
echo "</ul>";
echo "</div>";


	echo "<br/>";
		echo "<br/>";
			echo "<br/>";


   	     echo "<thead>";
    		echo "<tr>";
        	


		echo "<th>Distance</th>";
            echo "<th>Time</th>";
            echo "<th>Location</th>";
            echo  "<th>Date</th>";
            echo  "<th>Comments</th>";
            
		echo  "</tr>";
         

		echo "</thead>";
    

     echo "<tbody>";
    
         echo "<tr>";
        	echo "<td>1500m</td>";
           
            echo "<td>" . $list['fifteen'] . "</td>";
            echo "<td>" . $list['fifteenl'] . "</td>";
           	echo "<td>" . $list['fifteend'] . "</td>";
           	echo "<td>" . $list['fifteenc'] . "</td>";
         echo "</tr>";
    
         echo "<tr>";
        	echo "<td>Mile</td>";
          
            echo "<td>" . $list['mile'] . "</td>";
            echo "<td>" . $list['milel'] . "</td>";
           	echo "<td>" . $list['miled'] . "</td>";
           	echo "<td>" . $list['milec'] . "</td>";
         echo "</tr>";
    

 

So I have multiple fields that can be updated.  I'm fairly new to PHP, and would very much like to get this working.  As of now I can display the table with information dynamically called from the database, and the table data can be changed, but it doesn't update to the database.  Hopefully I've made my problem clear enough.  I know it can be accomplished, but I've tried for over a week now to do so with no success.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/130933-need-help-with-updating-database/
Share on other sites

When I change the data within the cell, it changes.  But when I refresh the page it goes back to the original data.  And it doesn't update. 

 

Here's an example of the TableKit: 

 

http://www.millstream.com.au/upload/code/tablekit/

 

And here is what they're telling me to do which I can't figure out for the life of me:

 

Updating the Cell

 

Each cell editor uses a Prototype Ajax Updater. The POST body is generated from the following:

 

'&row=n&cell=n&id=id&field=field&value=xxxxxx'

 

    * &row=n: The row index of the edited cell

    * &cell=n: The cell index of the edited cell

    * &id=id: The id attribute of the row, it may be useful to set this to the record ID you are editing

    * &field=field: The id attribute of the header cell of the column of the edited cell, it may be useful to set this to the field name you are editing

    * &value=xxxxxx: The rest of the POST body is the serialised form. The default name of the field is 'value'.

 

This information is POSTed to the URI specified in TableKit.options.editAjaxURI by default. If you initialise a table with options you can specify a different URI for each table. You can also specify a different URI in custom cell editors (see below)

 

Similarly the Ajax Updater uses the options from TableKit.options.editAjaxOptions

 

Here's a look at the Javascript section that refers to the update php page (which is called index.php): editAjaxURI : 'echo/index.php', 

 

The edited cell is calling this page.

 

I would be very grateful for a solution.  I've been trying to solve this thing for weeks.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.