PhP checkbox value issue

[php]public function get_on_checkbox1($i,$block,$block){

		$button_id="";

		if(isset($_POST[$block][$i])){

		$block = (isset($_POST[$block]))? 1: 0 ;

		}

		$button_id = $_POST[$block][$i];

		$q=$this->query("UPDATE schools set block ='$block' WHERE sch_id = $bbutton_id ");

		}

[/php]

the above code is working perfectly what i want but the problem is i have unlimited number of rows and i want to change the value of the row by sch_id but this code is not doing that if i remove the code WHere sch_id = $button_id it works but change the values of all lines not the checked lines but when i put this line in the code where sch_id = $button_id and press submit button

SQl syntax error please see the manual that correspond with the current vision of SQL showed up need any suggestion

ok so there is tons wrong here, the values that you use in the function should come from the values you are defining in the first line:
[php]
public function get_on_checkbox1($i,$block,$block){
[/php]

next why are you doing a double definition of $block?
it should be
[php]public function get_on_checkbox1($i,$block){
[/php]

next take the if isset post block out of the function!
it should be more like

[php]
public function get_on_checkbox1($block,$bbutton_id){

$q=$this->query("UPDATE schools set block =’$block’ WHERE sch_id = $bbutton_id ");
}
[/php]
do all the other checks before entering the values into the function this will make your life much easier
If you want to use the function to read post data then you have to define that

[php]public function get_on_checkbox1($_POST[’$block’], $bbutton_id)[/php]
then call the function on the page where the post data is being sent.
Your function was sending empty variables to the query because you did not have things properly defined.
I hope I explained that well If not someone will chime in :smiley:

if want to update the sql table via check box if box is tick then sql table value = 1 if uncheck the box vlaue updated = 0

where to define the code like

[php]if(isset($_POST[$block][$i])){

		$block = (isset($_POST[$block]))? 1: 0 ;

[/php]

if you could define a complete code

Sponsor our Newsletter | Privacy Policy | Terms of Service