Jump to content

[SOLVED] code that will check a form box help


randydg

Recommended Posts

I need a way to determin if the box is supose to be checked it will check it.

the code I have bellow just puts the word check under the box instead of actualy checking the box.

 

    <td width="69"><span class="style4">Priority:</span>
<input name="priority" type="checkbox" id="priority" value="1">
<?php 
// get Current pri value 
    $db = mysql_connect("ip","user","pass") or die("Couldn't connect"); 
    mysql_select_db("database",$db) or die("Couldn't select database");
	$query="SELECT `priority` FROM `calls` WHERE `worksheet` = '$worksheetnum'";
	$result=mysql_query($query);
	$num=mysql_numrows($result);
	$i=0;
	while ($i < $num) {
	$priority=mysql_result($result,$i,"priority");
	$i++;
	};
if ( $priority == 1 )
{ 
echo "checked "; }
else
// do nothing
?>

<?php 
// get Current pri value 
    $db = mysql_connect("ip","user","pass") or die("Couldn't connect"); 
    mysql_select_db("database",$db) or die("Couldn't select database");
	$query="SELECT `priority` FROM `calls` WHERE `worksheet` = '$worksheetnum'";
	$result=mysql_query($query);
	$num=mysql_numrows($result);
	$i=0;
	while ($i < $num) {
	$priority=mysql_result($result,$i,"priority");
	$i++;
	};
$checked = ($priority == 1) ? 'checked="checked"' : NULL;
        echo '<input name="priority" type="checkbox" id="priority" value="1" ' . $checked . '>';
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.