include?('../dev/phpdatagrid.php');
//?Establish?connection
$link?=?mysql_connect?('localhost',?'sa',?'pass');
//?Select?database
mysql_select_db('phpit');
//?##?Update?code?##?//
if?(DG_ACTION?==?'update')?{
????//?Get?article?id?of?row?that?is?being?updated
????$id?=?$_DATAGRID->data[DG_ROW]['articleid'];
????//?TODO:?Validation?code?for?the?id?(make?sure?it's?there,?and?a?valid?one)
????//?Get?updated?values
????$title?=?$_DATAGRID->update['title'];
????$description?=?$_DATAGRID->update['description'];
????//?TODO:?Validation?code?for?the?updated?values?(make?sure?they're?valid)
????//?Update?in?database
????$query?=?"UPDATE?article?SET?title?=?'"?.?mysql_escape_string($title)?.?"',?description?=?'"?.?mysql_escape_string($description)?.?"'?WHERE?articleid?=?"?.?$id;
????mysql_query?($query);
}
//?##?END?Update?Code?##?//
//?Query:
$query?=?"SELECT?articleid,?title,?description,?author,?datetimestamp?FROM?article?WHERE?publish?=?1";
//?Execute?query
$result?=?mysql_query?($query);
//?Get?articles
$articles?=?array();
while?($row?=?mysql_fetch_array($result,?MYSQL_ASSOC))?{
????array_push?($articles,?$row);
}
//?Bind?data
$_DATAGRID->bind?('article_dg',?$articles);
?>
????
????????PHP:DataGrid?Database?Editing?Example
????
????
????View?Source
????
????????
????????
?????????
????????
????????
????????
????????
????
????