Update DB from out of the CMS

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 30, 2012   (RSS)

Re: [mediaco] Update DB from out of the CMS

Hi,

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

Re: [greg] Update DB from out of the CMS

Great. Had to tweak it a little but it's working perfectly now. Thanks.