Log in

View Full Version : My CSS Won't Work On This Page



tomyknoker
04-04-2007, 06:12 PM
Can anyone see why my htm and css won't work on this page? I have done like 10 pages in a row fine and this one just ignores the stylesheet entirely...



<?php

if(empty($_SESSION['session_started']))
{
session_cache_expire(120);
session_start();
$_SESSION['session_started'] = "TRUE";
}

/* connect to the mysql database and use different queries for the count of members */

include 'library/config.php';
include 'library/opendb.php';

$info = mysql_query("SELECT * from `tblrepresentatives`");
?>

<!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">
<html>
<head>
<title>Members Status</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="cs_style.css" rel="stylesheet" type="text/css" />
<body>
<div id="wrap">
<div id="header"><p>Hello <? echo $_SESSION['txtUserId']; ?>! You are now Logged in.<a href="index.php">Logout</a></p></div>
<div id="nav"><?php include("nav.php"); ?></div>
<div id="main">
<p><img src="images/membership_status.png" alt="Membership Status"></p>
<div id="container">
<?php

echo '<table width="700" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th scope="col" class="twenty">FIRST NAME</th>
<th scope="col" class="twenty">LAST NAME</th>
<th scope="col" class="twenty">MEMBERS</th>
<th scope="col" class="twenty">EDIT</th>
<th scope="col" class="twenty">&nbsp;</th>
</tr>
</thead>';

//now check it for failure and display a decent error message if it did fail
if (!$info) {
die("Query failed. Query text: $query<br />Error Message: ".mysql_error());
}

else {
while ($qry = mysql_fetch_array($info)) {
$i++;

$rep = $qry['rep_NBR'];

$members = mysql_query("SELECT * FROM `tblmembers` WHERE `rep_NBR`='$rep'");

$total_members = mysql_num_rows($members);

//create the layout
?>

<tr valign="top" class="<?php echo $i % 2 ? 'odd' : 'even'; ?>">
<td><?php echo $qry['rep_Firstname']; ?></td>
<td><?php echo $qry['rep_Lastname']; ?></td>
<td><a href="showRepMembers.php?rep_id=<?=$qry['rep_NBR'];?>"><?=$total_members;?></a></td>
<td><a href="showRepEdit.php?rep_id=<?php echo $qry['rep_NBR']; ?>">Edit</a></td>
<td>Delete</td>
</tr>
<?php
}
}

echo '</table></div>
</div>
<div id="footer">
<p>Footer</p>
</div>
</body>
</html>';

include 'library/closedb.php';

?>

boogyman
04-04-2007, 08:05 PM
<?php echo $i % 2 ? 'odd' : 'even'; ?>

needs to be

<?php if($i%2 == 0) ? echo 'odd' : echo 'even' ?>

or

<?php

if($1%2 == 0) {
echo "odd";
}
else {
echo "even";
}
?>

they should produce the same thing

tomyknoker
04-05-2007, 12:21 AM
But the current code I'm using works is it incorrect?

boogyman
04-05-2007, 01:23 AM
Yes


<?php echo $i % 2 ? 'odd' : 'even'; ?>


This is incorrect. $i%2 must return 0 or 1, but what you are saying is if its true odd, if false then add the even clause. I didnt catch it the first time because I didnt take the time to look at it in depth... this code should be complete.

tomyknoker
04-05-2007, 02:49 PM
Ok but then how come it works in my page?

boogyman
04-05-2007, 05:52 PM
you said that it wasnt working? and now you are saying it is working? I guess I am not following what you are saying... It is possible that the interpreter is correctly adjusting the statement, but there is ambiguity within it and syntactically it is not correct. What you have currently is checking whether its true or false, using the modular ( % ) function returns the remainder, in this case either a 1 or a 0. Now this is where I am guessing the interpreter is bugging, since 1 and 0 have dual uses.

now as for the rest of your code, the only other `error` I can see off the top of my head is your query statement


$members = mysql_query("SELECT * FROM `tblmembers` WHERE `rep_NBR`='$rep'");

I may be wrong but I do not believe mysql queries support operational equalities.


$members = mysql_query("SELECT * FROM `tblmembers` WHERE `rep_NBR` LIKE '$rep'");