Forms and Tables

I am trying to create list of dates and events using information from a database. I have set up a table to display the data and a form inside it to manage the transfer of data from the database. However, the form annuls the table elements and attributes so that I cannot control column widths cell dimensions. Has anyone tried this and if so how did they get it to work?

I do not understand what you mean.

A FORM element is simply a block element and will take all the width possible.

the TABLE element will try to do the same but always constrained within the form since it seems to be the parent.

I do confess that I don’t use tables inside forms, never had the need of it. I just used tables for tabular data.

I can’t imagine which type of form requires a table in it but maybe it would be good if we could see the code. Could you post it?

Hi

Thanks for the offer of help. Here is the code:

<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/helpers.inc.php';?>
<!DOCTYPE html>
	<html lang = "en">
		<head>
			<meta charset = "utf-8">
				<title>About Us</title>
				<link rel = "stylesheet" type = "text/css" href = "AboutUs.css">
			<link rel = "stylesheet" type = "text/css" href = "header.css">
			
		</head>
		<body>		
			<img id = "background_body" src = "background2.jpg"/>
			<header id = "head">
			
				<h1 id = "head_h1">West Surrey National Trust Centre</>
				<h3 id = "head_h3">In support of the National Trust since 1971</h3>
				<p id = "head_p">in support of</p>
				<img  id = "head_img" src = "NTlogo.png"/>
				<nav>
					<ul>
						<li><a href = "index.php">Home</a></li>
						<li><a>Recent Events</a>
							<ul>
							
								<?php if (isset($visits)):
								htmlout("Found visits");?>
								
									<table class = "date" width = "40%">
									<caption>
										Recent Events
									</caption>
										<colgroup>
											<col class = "datecol">
											<col class = "visitcol">
										</colgroup>
										<tr>
											<th scope = "col">Date</th>
											<th scope = "col">Visit</th>
										</tr>
										<?php foreach($visits as $visit):?>	
											<form  action = "" method = "post">
												<tr>									
													<td><input type = "hidden" name = "id" value = "<?php htmlout($visit['id']);?>"></td>											
													<td  id = "date1"><input type = "submit" name = "visit"  value = "<?php htmlout($visit['lecturedate']);?>" ></td>											
													<td id = "visit1"><input type = "submit" name = "visit"	value = "<?php htmlout($visit['title']);?>"></td>	
												</tr>
											</form>	
										<?php endforeach;?>																			
									</table>									
								<?php endif;?>														
							</ul>
						</li>
						
						<li id = "forthcoming"><a>Forthcoming Events</a>
							<ul>							
								<li><a href = "#">Visits</a></li>
								<li><a href = "#">Lectures</a></li>
								<li><a href = "#">Walks</a></li>
								<li><a href = "#">Other Events</a></li>
								<li><a href = "#">News Sheet</a></li>						
							</ul>
						</li>
						
						<li><a href = "membership.html.php">Membership</a></li>
						<li><a href = "admin.html.php">Admin</a></li>
					</ul>
				</nav>
			
				
			</header>
			
			<div id = "strap">
				<h3>Make the most of your National Trust Membership - join the West Surrey Centre.</h3>
			</div>
			<div id = "sidebar">
			<p id = "sidebar_title1">Hatchlands</p>
			<img id = "background1" src = "background1.jpg"/>
			<img src = "hatchlands.jpg" id = "sidebar_img1"/>
			
			<p id = "sidebar_title2">Hindhead</p>
			<img src = "Hindhead.jpg" id = "sidebar_img2"/>
			</div>
			<div id = "main">
				<p>The West Surrey National Trust Centre is a voluntary association of National Trust members,
					established to promote the work of the National Trust.</p>
					<p>The West Surrey Centre is one of the most active and successful Centres in the Trust.   It covers a large area of Surrey encompassing towns like Cobham, Cranleigh, 
					Dorking, Esher, Farnham, Godalming, Guildford, Leatherhead, Walton, Weybridge, Woking and surrounding areas.</p>
					
					<p>We have a varied programme of visits, lectures, walks and social events; our annual General Meeting usually takes place in April.</p>
					
					<p>Membership is open to any NT Member.   An application form is included under the Membership button.</p>
					
					<p>If you are not already a member of the National Trust, details of how to join can be obtained at any National Trust property or by applying to Natinal Trust, FREEPOST NAT9775, Warrington WA5 7BR.
				</p>
			</div>
		</body>
	</html>

The reason I need the form is so as to be able to load data from the database ($visits) into the table from where I can link to a description of the visit via the index.php file, which selects and displays the correct entry from the database.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.