You are here: Ticking a check box based on a value from a record « All PHP « IT news, forums, messages
Ticking a check box based on a value from a record

Posted by Ian Davies on 05/27/06 23:32

Hello
I am retreiving records into a table (part of the code below)

<td width="20%" class="BodyText"><span class="style38"><?php echo
$commindex; ?></span></td>
<td width="10%" class="BodyText"><span class="style38"><?php echo
$username; ?></span></td>
<td width="45%" class="BodyText"><span class="style38"><?php echo
$comment; ?></span></td>
<td width="10%" class="BodyText"><span class="greenbody">
<input name="checkbox2" type="checkbox" value="<?php echo <td
width="20%" class="BodyText"><span class="style38"><?php echo $commindex;
?></span></td>
<td width="10%" class="BodyText"><span class="style38"><?php echo
$username; ?></span></td>
<td width="45%" class="BodyText"><span class="style38"><?php echo
$comment; ?></span></td>
<td width="10%" class="BodyText"><span class="greenbody">
<input name="checkbox2" type="checkbox" value="<?php echo
$available; ?>" MYFUNCTIONHERE>
</span></td>; ?>">
</span></td>


The last cell contains a check box, its value is set to $available. which is
a value of 1 or 0.
Trouble is I want the check box to be ticked if the value is 1 and unticked
if the value is 0
I thought of using a function such as

function checked($avail) {
if ($avail = $available) {
return 'checked';
}
}

after the value part of the code (where I have written MYFUNCTIONHERE)
which would put the work 'checked' in the appropriate place
but my inexperience means I cant get the syntax correct

can anyone help

Ian

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация