HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
adding a html checkbost to a php dynamic list
Post new topic   Reply to topic    HTML Help Forum Index -> PHP
View previous topic :: View next topic  
Author Message
greybeard



Joined: 18 Nov 2005
Posts: 2

PostPosted: Fri Nov 18, 2005 11:15 pm     adding a html checkbost to a php dynamic list Reply with quote

Hi

I am trying to create a roll.

I have a table being filled by a sql statement

What I am trying to do is put a check box in after the nemes so the student can be marked prsent or absent.

Is there a way I can get a check box in the 4th td ?
At the monet i have the the id, name and year in a table but am unable to get the checkbox on the same TR

echo '<table align="center" border="1" cellspacing="5" cellpadding="6">
<tr><td align="center"><b> Student_id </b></td>
<td align="center"><b> Student Name </b></td>
<td align="centre"><b> Year </b></td>
<td align="center"><b> Present </b></td></tr>';

// Fetch and display the records

while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
echo "<tr><td align=\"center\">$row[0]</td>
<td align=\"center\">$row[1]</td>
<td align=\"center\">$row[2]</td></tr>";
}

Any assistance would be great
degsy



Joined: 23 Feb 2005
Posts: 2440
Location: North East, UK

PostPosted: Sat Nov 19, 2005 7:57 am     Reply with quote

What is the value of your present field?
Best would be to have a True/False field or in mySQL a integer using 0 and 1

In this case it is using true or false
If present = true then check the box

Code:

<input <?php if (!(strcmp($row[3],true))) {echo "checked";} ?> type="checkbox" name="checkbox" value="checkbox" /></td>
greybeard



Joined: 18 Nov 2005
Posts: 2

PostPosted: Sat Nov 19, 2005 6:45 pm     Reply with quote

Yes it is a N or Y with N being the default.

default is 0 <absent> checked would be 1 <Present>

I will have a look and try it out.

thanks for the fast reply

Cheers
Greybeard
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial