473,395 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Ticking a check box based on a value from a record

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
May 27 '06 #1
1 1435
Ignore my question I just found it

if($available == 1){echo " CHECKED";}

Thanks for your time
Ian

"Ian Davies" <ia********@virgin.net> wrote in message
news:JH*****************@newsfe4-gui.ntli.net...
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

May 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
5
by: Derek Cooper | last post by:
I hope you can help me. I posted this in the microsoft sql server newsgroup a few days ago and got no response so I thought I'd try here. If I can provide any clarification I'll be glad to do so....
1
by: TP | last post by:
Hi, We use a servlet based application. I have noticed on one page that has a form that is displayed, the IE status bar just keeps on ticking forward. This is on the center of the status bar....
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
7
by: Neil | last post by:
I have a check box on a form that's bound to a function that returns a True/False value. When the user clicks on the check box, I run some code through the MouseDown event. Everything works fine. ...
1
by: scprosportsman | last post by:
Please help guys, i am trying to set up a database here at work and im fairly new to access in terms of writing functions and queries and stuff. I have 2 different places on my design that will...
2
by: amuth25 | last post by:
I have a form which displays records based on filter. I need the user to select a record or multiple records by clicking a check box and the selected record details should be displayed in a new form....
14
by: jacc14 | last post by:
Hi there. I am sure there is an easy solution to this and not sure why mine doesnt work? In the main form I have a "closed"tick box. In the sub form I also have several related records each...
1
by: angelicdevil | last post by:
i have listbox 1 which displays status , based on selection of status listbox 2 displays usernames. and based on username selected the textbox displays the email id. its working fine till...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.