G'day all:

Using php4.0.3pl1 I have a column in a MySQL table that is set to 
char(1) and is either empty or 'y' (if anyone knows of a better dual 
choice column type I'd be pleased to hear about it...however...)

In my update script I want a checkbox to be display as checked if 'y' 
is set in the afformentioned table. (The update script first SELECTS 
then displays the results in form fields in order to enable altering of 
their the contents (UPDATE/DELETE etc) All the other field types ( 
<select></select> and <input type="text" yadda yadda> ) are fine just 
the checkbox refuses to tell me the status of the column ('y' or empty)

This is the script snippet I thought may do it but doesn't:

while($chk_row = mysql_fetch_array($chk_result, $connection)) {
        $ischkd = $chk_row['chk'];
        if(!empty($ischkd)) {
                $chkbox = "<input type=\"checkbox\"             
                name=\"enable_sign\" value=\"yes\" checked>";
                }
        else{
                $chkbox = "<input type=\"checkbox\" 
                name=\"enable_sign\" value=\"yes\">";
                }
        }
        //end-while

echo "<td>$chkbox</td>
/*
Should echo as a checked-checkbox if 'y' exists in the table (the 'if')
Or an unchecked-checkbox (the 'else') if 'y' doesn't exist or the 
result is empty.
*/

I have also tried doing:

$num = mysql_num_rows($chk_result); 
if($num != 'y') {
                $chkbox = "<input type=\"checkbox\"             
                name=\"enable_sign\" value=\"yes\" checked>";
                }
        else{
                $chkbox = "<input type=\"checkbox\" 
                name=\"enable_sign\" value=\"yes\">";
                }

//But this don't work either!!??

Any suggestions are most welcome as the more coffee I consume the less 
rational my thought processes become!!

Cheers!

Russ


#-------------------------------------------------------#
                                
         "Believe nothing - consider everything"        
           "Web Developers do it on-the-fly."
                                                        
  Russ Michell
  Anglia Polytechnic University Webteam
  www.apu.ac.uk/webteam
  [EMAIL PROTECTED]
  +44 (0)1223 363271 ext 2331
  
  www.theruss.com
                        
#-------------------------------------------------------#


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to