PhP checkbox value

[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 but the problem is i have unlimited number of rows(comming dynamically by users) 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

you have

[php]
WHERE sch_id = $bbutton_id
[/php]

maybe is

[php]
where sch_id = $button_id
[/php]

ya that was a posting issue i have done that but still got the error

go ahead and add
[php]
or die(myslq_error());
[/php]
at the end of your query.

like this
[php]
$q=$this->query("UPDATE schools set block =’$block’ WHERE sch_id = $bbutton_id ") or die(myslq_error());
[/php]

also can you echo out the query and post the echo result so that i can see it.

the problem you having is in your query.

when i run the query this error appear

SQl syntax error please see the manual that correspond with the current vision of SQL

try
[php]
$q=$this->query(“UPDATE schools set block =’$block’ WHERE sch_id = ‘$button_id’”);
[/php]

replace the whole line, please copy and paste.

i did that but still the same problem :frowning:

post the code that calls the function please

[php]<?php

$q = $database->get_tbl_by_status(“schools”,1);
$count=$database->get_count(“schools”,0);

if(isset($_POST[‘save’])){

$database->get_on_checkbox1($i,"block","block");

}
?>[/php]

Thanks for responding m stuck in this its been 4th day please could you do something for me

I don’t know what the following lines do?

[php]

$q = $database->get_tbl_by_status(“schools”,1);
$count=$database->get_count(“schools”,0);

[/php]

$Sql is selecting the records from the table whose status = 1 we have to work on the records whos status is sett to 1

Can you post the results of your form submission? I’m having a hard time understanding what you need to do.

Just show me this, after submitting your form:

[php]
echo “

”;
print_r($_POST);
echo “
”;
[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service