DeanWhitehouse Posted April 29, 2008 Share Posted April 29, 2008 Can someone tell me why this code, div.left_bar { position:absolute; left:200px; width:auto; } table.logged_in { top:; } table.left_bar { border:#00FF00 groove; background-color:#000000; top:120px; } is only adjusting the the width of this <table class="logged_in"><tr><td> <p>Welcome, <?php echo $_SESSION['id_username']; ?> <br><a href="<?php echo "$home_page"; ?>/user_profile.php?id=<?php echo $_SESSION['user_id']; ?>">User Profile</a><br> <a href="<?php echo "$home_page"; ?>/user_setting.php">Settings</a><br> <a href="<?php print $_SERVER["PHP_SELF"]; ?>?logout=true">Logout</a><br /> </td></tr><tr><td>Logged In</td></tr></table></p> and not this <table class="left_bar"><tr><td> <a class="nav_bar" href="<?php echo "$home_page$main_page"; ?>">Home</a> </td></tr><tr><td><a class="nav_bar" href="<?php echo "$home_page/members.php"; ?>">Members</a></td></tr> <tr><td><a class="nav_bar" href="<?php echo "$home_page/forum.php"; ?>">Forum</a></td></tr> </table> what i want it to do, is the whole nav_bar all be the same width, so if the user has a long username the whole nav bar changes width not just part of it this is my whole code <div class="left_bar"> <?php /*Random Game Design: PHP Website Template/CMS Version 1 Copyright Dean Whitehouse, 2008*/ if (isset($_GET['logout'])) { setcookie("uname", $_SESSION['id_username'], time() - 86400*100); setcookie("userpw", $user_password, time() - 86400*100); setcookie("check",$checked, time() - 86400*100); session_unset(); session_destroy(); } if ($_SESSION['is_valid'] == true) { if ($_SESSION['user_level'] == 2) { ?> <table class="logged_in"><tr><td> <p>Welcome, <?php echo $_SESSION['id_username']; ?> <br><a href="<?php echo "$home_page"; ?>/user_profile.php?id=<?php echo $_SESSION['user_id']; ?>">User Profile</a><br> <a href="<?php echo "$home_page"; ?>/user_setting.php">Settings</a><br> <a href="<?php print $_SERVER["PHP_SELF"]; ?>?logout=true">Logout</a><br /> </td></tr><tr><td>Logged In</td></tr></table></p> <?php } if ($_SESSION['user_level'] == 1) { ?> <table class="logged_in"><tr><td> <p>Welcome, <?php echo $_SESSION['id_username']; ?> <br><a href="<?php echo "$home_page"; ?>/user_profile.php?id=<?php echo $_SESSION['user_id']; ?>">User Profile</a><br> <a href="<?php echo "$home_page"; ?>/user_setting.php">Settings</a><br> <a href="<?php echo "$home_page"; ?>/admin/admin_centre.php">Admin Area</a><br> <a href="<?php print $_SERVER["PHP_SELF"]; ?>?logout=true">Logout</a><br /> </td></tr><tr><td>Logged In</td></tr></table></p> <?php } } else { require_once 'includes/db_connect.php'; if ($_SESSION['is_valid'] == false) { if (isset($_POST['login'])) { $user_name = mysql_real_escape_string($_POST["user_name"]); $user_password = mysql_real_escape_string($_POST["user_password"]); $cookiename = forumcookie; $verify_username = strlen($user_name); $verify_pass = strlen($user_password); if ($verify_pass > 0 && $verify_username > 0) { $userPswd = md5($user_password); $userpwsd = sha1($userPswd); $sql = "SELECT * FROM $user WHERE user_name='$user_name' AND user_password='$userpwsd' LIMIT 1;"; $result = mysql_query($sql) or die(mysql_error() . " in $sql"); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); $s_userpass = serialize($userpass); $_SESSION['id_username'] = $row['user_name']; $_SESSION['id_user_password'] = $row['user_password']; $_SESSION['user_level'] = $row['userlevel']; $_SESSION['user_id'] = $row['user_id']; $_SESSION['is_valid'] = true; //change the session variable name to what you want, just remember it for all files if (isset($_POST['remember'])) { $checked = "checked='checked'"; setcookie("uname", $_SESSION['id_username'], time() + 86400*100); setcookie("userpw", $user_password, time() + 86400*100); setcookie("check",$checked, time() + 86400*100); } header("Location:http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]); } else { echo "Login failed. Username and Password did not match database entries."; } } else { echo "Form was not completed. Please go back and make sure that the form was fully completed."; } } $server = str_replace("?logout=true","",$_SERVER['PHP_SELF']); ?> <table bgcolor="#999999" align="right"><form action=" <?php echo "$server"; ?> " method="post"> <tr><td>Username: </td><td><input type="text" name="user_name" value="<?php echo $_COOKIE['uname']; ?>" /><br /></td></tr> <tr><td>Password:</td><td> <input type="password" name="user_password" value="<?php echo $_COOKIE['userpw'] ?>" /><br /></td></tr> <tr><td><input type="hidden" name="login" value="true"><input type="submit" value="Submit"></td></tr> <tr><td><input type="checkbox" name="remember" <?php echo $_COOKIE['check'] ?>> Remember Me </td></tr><tr><td><a href="register.php">[Register]</a></td></tr><tr><td><a href="forgot_password.php">[Forgot Password?]</a></td></tr></table> </form> <?php mysql_close(); } } ?> <?php require_once "includes/main.inc.php"; if ($_SESSION['is_valid'] == true){ ?> <table class="left_bar"><tr><td> <a class="nav_bar" href="<?php echo "$home_page$main_page"; ?>">Home</a> </td></tr><tr><td><a class="nav_bar" href="<?php echo "$home_page/members.php"; ?>">Members</a></td></tr> <tr><td><a class="nav_bar" href="<?php echo "$home_page/forum.php"; ?>">Forum</a></td></tr> </table> <?php } else { ?> <a class="left_bar" href="<?php echo "$home_page$main_page"; ?>">Home</a> </td></tr><tr><td><a class="nav_bar" href="<?php echo "$home_page/members.php"; ?>">Members</a></td></tr> <?php } ?> </div> Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted April 29, 2008 Share Posted April 29, 2008 Please post only parsed html code. NO PHP. :-X PHP is a server side language that has no effect on the presentation of content, only the markup. "Clutter" all it is. Quote Link to comment Share on other sites More sharing options...
GameYin Posted April 29, 2008 Share Posted April 29, 2008 div.left_bar { position:absolute; left:200px; width:auto; } <table class="logged_in"><tr><td> <p>Welcome, <?php echo $_SESSION['id_username']; ?> <br><a href="<?php echo "$home_page"; ?>/user_profile.php?id=<?php echo $_SESSION['user_id']; ?>">User Profile</a><br> <a href="<?php echo "$home_page"; ?>/user_setting.php">Settings</a><br> <a href="<?php print $_SERVER["PHP_SELF"]; ?>?logout=true">Logout</a><br /> </td></tr><tr><td>Logged In</td></tr></table></p> You probably have a div up there. Also, for this table, you don't have any cells. Your CSS isn't applying to the other thing because it has cells, and your CSS doesn't specify that. And PLEASE, post the parsed HTML code: go to your website and hit view source and copy and paste the part here. Quote Link to comment Share on other sites More sharing options...
dbrimlow Posted April 29, 2008 Share Posted April 29, 2008 You have quite a few mark-up html issues (closing p tag AFTER closing table tag!!) But here's your main layout problem: position:absolute; left:200px; width:auto; Why are you using position:absolute? First, this takes the div out of the flow of html and it is not a "wrapper". Width:auto means nothing. designating "top", "left", etc in an element that doesn't also specify "position:absolute" means nothing ... like these: table.logged_in { top:; } table.left_bar { border:#00FF00 groove; background-color:#000000; top:120px; } Your layout is never going to work using this, and it is simply too wrong to even advise you how to fix it. Get a book on css basics instead of trying to guess; it will save you months of frustration. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted April 30, 2008 Author Share Posted April 30, 2008 just to say that i have already solved this on my own, and i know CSS and what i have works. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.