Update DB from out of the CMS
3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 30, 2012 (RSS)
By mediaco - November 29, 2012
In my cms, I have a table (sc_orders) which has a checkbox field named "printed".
The contents of "sc_order" are shown in a list page and then a detail page for each record. And the value of printed is echoed on the list page. Basically to show if the detail page has been printed or not.
Is it possible to have a checkbox on the detail page, that when checked updates the value of "printed" in the DB?
This will then automatically be echoed in the list page.
I had thought this might be posible using mysql_update?
The contents of "sc_order" are shown in a list page and then a detail page for each record. And the value of printed is echoed on the list page. Basically to show if the detail page has been printed or not.
Is it possible to have a checkbox on the detail page, that when checked updates the value of "printed" in the DB?
This will then automatically be echoed in the list page.
I had thought this might be posible using mysql_update?
Re: [mediaco] Update DB from out of the CMS
Hi,
Your definitely on the right track. I would do something like this.
html code:
and the PHP code:
Let me know if you need a hand integrating this code.
Thanks
Your definitely on the right track. I would do something like this.
html code:
<form action="" method="post" >
<!-- input to check if the form has been submitted -->
<input type="hidden" name="checkBoxUpdate" value="yes" />
<!-- num field of entry that needs to be updated in section -->
<input type="hidden" name="numValue" value="3">
<!-- checkbox input -->
<input type="checkbox" name="printed" value="1">
<input type="submit" value="submit" name="sumit" >
</form>
and the PHP code:
//if the form has been submitted and the value of printed is equal to one...
if(@$_REQUEST['checkBoxUpdate'] && @$_REQUEST['printed'] =='1'){
//get the row that needs updating....
$updateNum = intval($_REQUEST['checkBoxUpdate']);
//and update the table
mysql_update('sc_order', $updateNum, NULL, array('printed' => '1'));
}
Let me know if you need a hand integrating this code.
Thanks
Greg Thomas
PHP Programmer - interactivetools.com
PHP Programmer - interactivetools.com
Re: [greg] Update DB from out of the CMS
By mediaco - November 30, 2012
Great. Had to tweak it a little but it's working perfectly now. Thanks.