Jump to content

Recommended Posts

Hi,

 

I might be being extremely dim, however, I can't for the life of me get certain aspects of the page to style despite putting a div around it.

 

Anywhere where I have an echo statement with a div class or ID in it makes no difference to the output from the database.

 

It's the first time I've done anything like this so I am learning as I am going along..

 

(note, anything not inside the php tags styles fine).

 

Here is my code;

 

<?php $pagetitle = "";?>
<?php include("../includes/headerDivisions.php");?>

<?php include("../includes/navigation.php");?>

<?php include("../functions.php");?>


<div id="contentArea">

	<div id="mainContent">

	<h1>Division 1 Team Contacts</h1>
	<br />
	<br />

		<?php
		// Make a MySQL Connection
		connectDatabase();


$sql="SELECT * FROM team";
$result=mysql_query($sql);

//**********Basically this section that isn't styling at all where I am using echo followed by a div**********

echo "<div id='teamDetails'>";
// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){

echo "<div class='teamName'><p>",$rows[teamName],"</p></div>";
echo "<div class='teamInner'><p>Team Secretary: ",$rows[teamSecretary],"</p>";
echo "<p>Team Contact Number: ",$rows[teamContactNo],"</p>";
echo "<p>Team Colours Home: ",$rows[teamColoursHome],"</p>";
echo "<p>Team Colours Away: ",$rows[teamColoursAway],"</p>";
echo "<p>Team Pitch: ",$rows[teamPitch],"</p><br /><br /><hr></div>";

// close while loop
}

echo "</div>";

mysql_close();

?>

</div><!--mainContent end-->

<?php include("../includes/sidebar.php");?>


</div><!--contentArea end-->


<?php include("../includes/footer.php");?>

 

All help would be greatly appreciated.

 

Many thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/242475-div-classesids-not-working-when-echoing/
Share on other sites

Try swapping the double and single quotes.

echo '<div id="teamDetails">';

 

Also you don't concencate strings in PHP with comma, you do it with period.

echo "<div class='teamName'><p>" . $rows[teamName] . "</p></div>";

 

2nd also you should use single quotes around non numeric array indexes, otherwise PHP will parse them as constants and this will give you notices if you have reporting set right

$rows['teamName']

Thanks TeNDoLLA, I have actually deduced that background colours are working fine. It is actually just the font styling which I can't get working. I have absolutely no problem with CSS at all, I just can't get it to integrate fully with my PHP code.

 

Thanks for the pointers though, I've ammended that now.

So what problems you are having then now? I just made a simple test case and font styling works just fine.

 

<html>
<head>
<style type="text/css">
.test {
font-size: 14px;
font-family: Verdana;
}
</style>
</head>
<body>
<?php echo '<div class="test">Some text here..</div>'; ?>
</style>
</html>

The problem is that no matter what styling I put in for the fonts within that div it just ignores them.. I can set margins, padding, background colours etc, but the font styling isn't working.

 

I did try swapping single quotes with double, but that didn't seem to make a difference. Can't see what I am doing wrong here to be honest!

I've sort of made progress.

 

If I use #mainContent which is the entire surround ID around the whole of the content area then I can get the font-styling to work providing it is used as a paragraph class. If I stick div tags around the teamName without the paragraph class then refuses to style. Perhaps switching the quotes back to how you suggested may help..

 

/********** Team Contact Details **********/
#mainContent #teamDetails {
width: 800px;

margin:0 auto;
background-color:#FFFFFF;
font-family:Arial, Helvetica, sans-serif;
}

.teamDetailRow {
width: 800px;
margin:0 auto;
}

#mainContent .teamName {
font-size:16px;
}

I tried with your code, and it works exactly like you have defined the CSS. I simplified the code a little (without getting data from mysql). So don't really get the problem.

<html>
<head>
<style type="text/css">
	/********** Team Contact Details **********/
	#mainContent #teamDetails {
		width: 800px;
		margin: 0 auto;
		background-color: #FFFFFF;
		font-family: Arial, Helvetica, sans-serif;
		/* font-size: 30px; this was jsut to test.. */
	}
	.teamDetailRow {
		width: 800px;
		margin: 0 auto;
	}
	#mainContent .teamName {
		font-size: 26px;
	}
</style>
</head>
<body>
<div id="contentArea">
	<div id="mainContent">
		<h1>Division 1 Team Contacts</h1>
		<br />
		<br />
		<?php
		$testText = 'Some CSS testing..';
		echo "<div id='teamDetails'>";
		echo "<div class='teamName'><p>". $testText ."</p></div>";
		echo "<div class='teamInner'><p>Team Secretary: ". $testText ."</p>";
		echo "<p>Team Contact Number: ". $testText ."</p>";
		echo "<p>Team Colours Home: ". $testText ."</p>";
		echo "<p>Team Colours Away: ". $testText ."</p>";
		echo "<p>Team Pitch: ". $testText ."</p><br /><br /><hr></div>";
		echo "</div>";
		?>
	</div><!--mainContent end-->
</div><!--contentArea end-->
</body>
</html>

Apologies, it's extremely messy!

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Division 1 Fixtures | Langbaurgh Sunday League</title><link rel="stylesheet" type="text/css" href="../style.css" />
<link rel="stylesheet" type="text/css" href="../jqueryslidemenu.css" />
<link rel='stylesheet' type='text/css' href='../stylePHP.php' />

<!--[if lte IE 7]>
<style type="text/css">
html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/
</style>
<![endif]-->

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript" src="../jqueryslidemenu.js"></script>
</head>

<body>

<div id="wrapper">

<div id="header">
	<h1>Langbaurgh Sunday League</h1>
</div><!--header end-->
<div id="myslidemenu" class="jqueryslidemenu">
	<ul>
		<li><a href="http://www.dynamicdrive.com">League News</a></li>

		<li><a href="http://www.dynamicdrive.com">About</a></li>
		<li><a href="#">Division 1</a>
			  <ul>
			  <li><a href="../division1/div1Fixtures.php">Fixtures</a></li>
			  <li><a href="../division1/division1Table.php">League Table</a></li>
			  <li><a href="../division1/division1Contacts.php">Club Details</a></li>

			  </ul>
		</li>
		<li><a href="#">Division 2</a>
			  <ul>
			  <li><a href="../division2/div1Fixtures.php">Fixtures</a></li>
			  <li><a href="../division2/div1Table.php">League Table</a></li>
			  <li><a href="../division2/clubDetails.php">Club Details</a></li>

			  </ul>
		</li>
		<li><a href="#">Division 3</a>
			  <ul>
			  <li><a href="../division3/div1Fixtures.php">Fixtures</a></li>
			  <li><a href="../division3/div1Table.php">League Table</a></li>
			  <li><a href="../division3/clubDetails.php">Club Details</a></li>

			  </ul>
		</li>
		<li><a href="#">Cup Competitions</a>
			  <ul>
			  <li><a href="../cupCompetitions/leaguecup.php">League Cup</a></li>
			  <li><a href="../cupCompetitions/terrysmith.php">Terry Smith</a></li>
			  <li><a href="../cupCompetitions/terrymay.php">Terry May</a></li>

			  </ul>
		</li>

		<li><a href="#">League History</a></li>
		<li><a href="#">League Documents</a></li>
		<li><a href="#">Contact Us</a></li>

		</ul>
		<br style="clear: left" />

  </div><!--navigation end-->



<div id="contentArea">

	<div id="mainContent">
	<h1>LSL Division 1 Team Contacts</h1>

	<br />
	<br />

		<div id='teamDetails'><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>Acklam Electrical</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Matty Mitchell - 01642123456 / 07777 777777 - matty.mit@abc.com</p><p class='teamAllDetails'><b>Assistant Secretary:</b>  -  /  - </p><p class='teamAllDetails'><b>Home Colours:</b> Red & Black</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Mill Hill</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>Cleveland Cable</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Anthony Massingham - 01642123456 /  - </p><p class='teamAllDetails'><b>Assistant Secretary:</b>  -  /  - </p><p class='teamAllDetails'><b>Home Colours:</b> Yellow</p><p class='teamAllDetails'><b>Away Colours:</b> Black</p><p class='teamAllDetails'><b>Home Venue:</b> Pallister Park</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>Dormans FISC</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Alan Hodgeson - 01642123456 /  - </p><p class='teamAllDetails'><b>Assistant Secretary:</b>  -  /  - </p><p class='teamAllDetails'><b>Home Colours:</b> Red & Black</p><p class='teamAllDetails'><b>Away Colours:</b> Blue & White</p><p class='teamAllDetails'><b>Home Venue:</b> Acklam Sports Centre</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>Marton Rovers</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Ged Anderson - 01642123456 /  - </p><p class='teamAllDetails'><b>Assistant Secretary:</b>  -  /  - </p><p class='teamAllDetails'><b>Home Colours:</b> Yellow & Blue</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Pallister Park</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>Marton Taxis</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Bryan Brown Coat - 01642123456 /  - </p><p class='teamAllDetails'><b>Assistant Secretary:</b>  -  /  - </p><p class='teamAllDetails'><b>Home Colours:</b> Yellow & Black</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Pallister Park</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>Ormesby FC</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Andy Mallaby - 01642123456 /  - </p><p class='teamAllDetails'><b>Assistant Secretary:</b>  -  /  - </p><p class='teamAllDetails'><b>Home Colours:</b> Green & White</p><p class='teamAllDetails'><b>Away Colours:</b> Red</p><p class='teamAllDetails'><b>Home Venue:</b> Eston Sports Academy</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>Park End</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Old Steve - 01642 123456 /  - steve.phelps@lsl.co.uk</p><p class='teamAllDetails'><b>Assistant Secretary:</b> Mr Lan - 01642 111000 /  - mr.lan@hotmail.co.uk</p><p class='teamAllDetails'><b>Home Colours:</b> Navy & White</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Ormesby Rd</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>Roseberry Park</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Steve Coates - 01642123456 /  - </p><p class='teamAllDetails'><b>Assistant Secretary:</b>  -  /  - </p><p class='teamAllDetails'><b>Home Colours:</b> Green & White</p><p class='teamAllDetails'><b>Away Colours:</b> Blue & White</p><p class='teamAllDetails'><b>Home Venue:</b> Mill Hill</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>South Bank</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Mr. Nice Guy - 01642123456 /  - </p><p class='teamAllDetails'><b>Assistant Secretary:</b>  -  /  - </p><p class='teamAllDetails'><b>Home Colours:</b> Red</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> South Bank</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>The Black Swan</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Sean Thompson - 01642123456 /  - </p><p class='teamAllDetails'><b>Assistant Secretary:</b>  -  /  - </p><p class='teamAllDetails'><b>Home Colours:</b> Blue & Black</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Prissick</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>The Cleveland</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Ben Jamin - 01642123456 /  - </p><p class='teamAllDetails'><b>Assistant Secretary:</b>  -  /  - </p><p class='teamAllDetails'><b>Home Colours:</b> Blue & Black</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Mill Hill</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>Village Park Rangers</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Gary Stonehouse - 01642123456 /  - </p><p class='teamAllDetails'><b>Assistant Secretary:</b>  -  /  - </p><p class='teamAllDetails'><b>Home Colours:</b> White & Black</p><p class='teamAllDetails'><b>Away Colours:</b> Yellow & Blue</p><p class='teamAllDetails'><b>Home Venue:</b> Mill Hill</p><br /><br /></div></div><!--teamdetailrow end--></div>

</div><!--mainContent end-->

<div id="leftSidebar">

		<h2>Latest News!</h2>

	</div><!--sidebar end-->

</div><!--contentArea end-->


<div id="footer">

	<p>© Langbaurgh Sunday League 2011</p>


</div><!-- footer end-->



</div><!--wrapper end-->

</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.