Hi,

I am trying to run a query once and then reuse the result set in a loop to compare so that to know whether to have a checkbox "checked" or not. Something is not right because I don't get any of them checked. I have a feeling I need something like an BOF statement but I am not sure of the syntax.
Thanks, here is the code:

$query = "select * from tblService_County where serviceid = {$serviceid};";
if( !$c->query($query) ){
	echo "error querying to the db. $query";
	echo $c->getError();
	exit();
}

$selectedcounty=mysql_query($query);

$numselectedcounty=mysql_numrows($selectedcounty);


while($county = $c->getObject() ){
echo "<br>{$county->county}</td><td><input type=\"checkbox\" name=\"county[]\" value = \"{$county->countyid}\" ";
$i=0;
[B]while ($i < $numselectedcounty) 
{
if($selectedcounty->countyid == $county->countyid )
		echo "checked";
$i++;
}[/B]echo "><br>\n";
}

I think there is no function like mysql_numrows, Its mysql_num_rows

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.