Jump to content

Akenatehm

Members
  • Posts

    262
  • Joined

  • Last visited

    Never

Everything posted by Akenatehm

  1. Hey Guys, I need a bit of help here. I have a little script here running. The javascript part is a rollover that changes the CSS class on hover of the <div> element. The div element and its contents are given from a PHP loop which displays news entries inside the main div. When I hover over any of the news entries, the same one div at the top changes (in its rollover effect). What I want, is a way for each one to change its own, and not eachothers. So it would need to create a new id for each one and work with the javascript somehow. Here's the javascript: <script type="text/javascript"> function mouseOver() { document.getElementById('entry').className = "hoverentry"; } function mouseOut() { document.getElementById('entry').className = "normalentry"; } </script> and the PHP <?php $connect = mysql_connect($host,$user,$pass) or die(mysql_error()); $selectdatabase = mysql_select_db($db) or die(mysql_error()); $getentries = mysql_query("SELECT * FROM newsentries ORDER BY newsid DESC ") or die(mysql_error()); while($filterentries = mysql_fetch_assoc($getentries)) { $newsid = $filterentries['newsid']; $title = $filterentries['title']; $content = substr($filterentries['content'],0,200); $author = $filterentries['author']; $date = $filterentries['date']; echo '<div class="normalentry" id="entry" onMouseOver="mouseOver()" onMouseOut="mouseOut()">'; echo '<h3 class="newsentry">' . "$title " . "</h3>"; echo '<p class="newsdate">' . "$date" . "</p> <br />"; echo '<p class="newsentry">' . "$content" . '......</p>'; echo '<p class="newsposter">Posted By ' . "$author"; ?> I have only just started with javascript, that's why I don't know very much. Help would be appreciated.
  2. Any ideas guys?
  3. OK I tried that. Now The background is white, on hover over goes to the right colour. Also, When i hover over, it like shakes the page and moves everything a few pixels left or right. Any ideas?
  4. I knew that I was assigning them to the same ID. I just didnt know how else to do it. So, i changed using the CSS. Now, there is no hover effect. How can i fix this?
  5. I did have it in there. But I removed it because I thought it wasn't working (the real reason was because i didnt have my rank "Owner" in the Database). I added that all in and its all working fine. Thanks GUys.
  6. Ok this is what I have: <?php $getuserpriviliges = mysql_query("SELECT rank FROM users WHERE username = '$username'") or die(mysql_error()); if(in_array($getuserpriviliges, array("Owner","Admin","Owner/Admin","Administrator"))) { echo '<a class="readmore"href=\"read_more.php?newsid=$id\">Read More</a>'; echo '<a class="readmore"href=\"edit_news.php?newsid=$id\">Edit</a>'; echo '<a class="readmore"href=\"edit_news.php?newsid=$id\">Delete</a></p> </div>'; } else { echo '<a class="readmore"href=\"read_more.php?newsid=$id\">Read More</a></p> </div>'; } } } ?> Mchls solution did not seem to work.
  7. That code will not work I'm afraid. read the previous replies. Ok, now they both are only showing Read More, even when I am logged in. How can I make it work?
  8. Hey Guys, I have a little script here running. The javascript part is a rollover that changes the CSS class on hover of the <div> element. The div element and its contents are given from a PHP loop which displays news entries inside the main div. The Javscript is: <script type="text/javascript"> function mouseOver() { document.getElementById('entry').className = "hoverentry"; } function mouseOut() { document.getElementById('entry').className = "normalentry"; } </script> The PHP is: $connect = mysql_connect($host,$user,$pass) or die(mysql_error()); $selectdatabase = mysql_select_db($db) or die(mysql_error()); $getentries = mysql_query("SELECT * FROM newsentries ORDER BY id DESC "); while($filterentries = mysql_fetch_assoc($getentries)) { $title = $filterentries['title']; $content = $filterentries['content']; $author = $filterentries['author']; $date = $filterentries['date']; echo '<div id="entry" class="normalentry" onMouseOver="mouseOver()" onMouseOut="mouseOut()">'; echo '<h3 class="newsentry">' . "$title " . "</h3>"; echo '<p class="newsdate">' . "$date" . "</p> <br />"; echo '<p class="newsentry">' . "$content" . '</p>'; echo '<p class="newsposter">Posted By ' . "$author" . "</p> </div>"; } and the CSS is:(I dont think you need it but just in case.) div.normalentry{ margin-top: 10px; margin-bottom: 10px; background-color: #2a2a2a; background-image: url('scanline.png'); width:570px; } div.hoverentry{ margin-top: 10px; margin-bottom: 10px; background-color: #111111; background-image: url('scanline.png'); width:570px; } h3.newsentry{ color: white; font-size:24; padding:15px 10px 2px 10px; font-family: sans-serif; } p.newsdate{ color:white; font-size:12; display: inline; padding: 3px 0px 0px 25px; } p.newsentry{ color: #959292; padding: 15px 10px 10px 10px; } p.newsposter{ color:white; font-size: 14; padding-left: 12px; padding-top: 5px; padding-bottom: 15px; } When I hover over any of the news entries, the same one div at the top changes (in its rollover effect). What I want, is a way for each one to change its own, and not eachothers. Help would be appreciated.
  9. Thanks plutomed. Works fine. Much appreciated!
  10. Hey Guys, Just need to know if this is the right way to things: $getuserpriviliges = mysql_query("SELECT rank FROM users WHERE username = '$username'") or die(mysql_error()); if($getuserpriviliges == 'Owner' || 'Admin' || 'Owner/Admin' || 'Administrator') { //Execute this Code }
  11. Wow. I really am stupid LOL. I didn't have data in the DB...that was really dumb.... Thanks for your help...well making me thing about the obvious. Appreciate it. Cya Around.
  12. <?php while ($row = mysql_fetch_assoc($result)){ $title = $row['title']; $url = $row['url']; echo " <tr> <td><a href=\"$url\" target=\"http://www.freefreeads.com\">$title</a></td> </tr> "; } print " </table>\n"; echo "yourlink.html"; //Put it here. ?>
  13. Which script is doing what? Are they on the same page?
  14. Explain what you are trying to do with each script and what you want it to do. Then I can help better.
  15. You might want to auto redirect them when they submit the form. YOu can do it like this: <?php header("Location: process.html"); ?> At the bottom of your script. Hope that's what you wanted.
  16. Thanks Festy. I was wondering what fry2010 was talking about? Where is a better place to connect? If I connect through another function, will it still be connected and ready to use in other functions? Or If I connect through a main php page, will that also be usable in other functions? Like I said, I am not getting errors, just blank white space with no echoed data.
  17. Hey Guys, I am trying to make a news script that echoes the results through a loop. CUrrently, nothing is coming up on the page. Here's index.php: <?php include 'functions.php'; ?> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Exclusive Mac - Home</title> <link rel="stylesheet" href="styles.css" type="text/css" /> <script type="text/javascript"> function mouseOver() { document.getElementById('entry').className = "hoverentry"; } function mouseOut() { document.getElementById('entry').className = "normalentry"; } </script> </head> <body> <div class="header"> <img src="images/header.png" alt="Header" /> </div> <ul id="nav"> <li><a href="#">Home</a></li> <li><a href="#">News</a></li> <li><a href="#">Forums</a></li> <li><a href="#">Applications</a></li> <li><a href="#">Other</a></li> </ul> <?php writeNewsEntry(); ?> </body> </html> and here's functions.php <?php function writeNewsEntry() { $user = "user"; $pass = "pass"; $host = "localhost"; $db = "exclusivemac"; $connect = mysql_connect($host,$user,$pass); $selectdatabase = mysql_select_db($db); $getentries = mysql_query("SELECT * FROM newsentries"); while($filterentries = mysql_fetch_assoc($getentries)) { $title = $filterentries['title']; $content = $filterentries['content']; $author = $filterentries['author']; $date = $filterentries['date']; echo '<div id="entry" class="normalentry" onMouseOver="mouseOver()" onMouseOut="mouseOut()">'; echo '<h3 class="newsentry">' . "$title - " . "</h3>"; echo '<p class="newsdate">' . "$date" . "</p> <br />"; echo '<p class="newsentry">' . "$content" . '</p>'; echo '<p class="newsposter">Posted By' . "$author" . "</p> </div>"; } } ?> Help Would be Appreciated.
  18. I have, and the DIV tag doesnt expand for it.
  19. Thanks for that. Works great now. One other thing. I have set a background colour for a DIV through CSS and I want to be able to echo into the DIV and make it auto extend. Is this possible?
  20. Hey Guys, I am trying to create a mini news system. Here is the code: <html> <body> <?php $dbhost = "localhost"; $dbuser = "user"; $dbpass = "pass"; $dbname = "game"; $connect = mysql_connect($dbhost,$dbuser,$dbpass); $selectdb = mysql_select_db($dbname); $selectentries = mysql_query("SELECT * FROM news"); $filterentries = mysql_fetch_assoc($selectentries); $title = $filterentries['title']; $content = $filterentries['content']; $author = $filterentries['author']; $date = $filterentries['date']; $arr=array("$title" ); foreach ($arr as $value) { echo "$title - " . "$date" ."<br /> <br /> "; echo "Content: " . $content . "<br /> <br />"; echo "Posted By: " . "$author <br />"; } ?> </body> </html> It is only displaying the first entry in the database. Could you please help me in making it show all of them. Thanks in Advanced, Cody
  21. Hey Lol. I found out their were a few reasons why it wasn't working. Firstly, I didn't set the variable $username to be checked before it was checked. Secondly, I had set a 20 char limit in the table to the password field so it was only accepting 20 of the should be 32 md5 pass chars ther shud have been. After fixing, it is algud.
  22. Hey Guys, This script doesn't seem to be creating and checking sessions properly. When I click submit, it just resets the page. Heres the functions I'm calling from functions.php: function startusersession() { session_start(); $_SESSION["loggedin"]; } function endsession() { foreach($_SESSION as $key => $val) unset($_SESSION[$key]); } function checksession() { if (isset($_SESSION['loggedin']) && $_SESSION['loggedin']) { header("Location:alreadyloggedin.php"); } } and here's login.php <?php include 'functions.php'; include 'connect.php'; checksession(); if (isset($_POST['submit'])) { if($_POST['password'] != $_POST['confirmpassword']) { $result = '<font color="red">Passwords Do Not Match</font>'; } else{ $checkuserexists = mysql_query("SELECT * FROM accounts WHERE username = '$username'"); if(mysql_num_rows($checkuserexists) > 0) { $result = '<font color="red">User Does Not Exist</font>'; } else { $usersdetails = mysql_fetch_assoc($checkuserexists); $usersusername = $usersdetails['username']; $userspassword = $usersdetails['password']; $formusername = $_POST['username']; $formpass = $_POST ['password']; if($formusername != $usersusername || $formpass != $userspassword) { $result = "Incorrect Username or Password"; } else { startusersession(); headers("Location:loggedin.php"); } } } } ?> <html> <head> <title>Login - Fall of The Empire</title> <link rel="stylesheet" href="styles.css" type="text/css"/> </head> <body bgcolor="272d31"> <div align="center" class="header"> <img src="images/logo.png" width="473" height="227" alt="Logo"> </div> <br> <center> <div class="main"> <div class="navbar"> <img src="images/nav_top.png" width="232" height="46" alt="Nav Top"><br> <a href="index.php"><img src="images/nav_home.png" width="232" height="33" alt="Nav Home" border="0"></a><br> <a href="news.php"><img src="images/nav_news.png" width="232" height="32" alt="Nav News" border="0"></a><br> <a href="about.php"><img src="images/nav_about.png" width="232" height="23" alt="Nav About" border="0"></a><br> <a href="login.php"><img src="images/nav_login.png" width="232" height="32" alt="Nav Login" border="0"></a><br> <a href="register.php"><img src="images/nav_register.png" width="232" height="25" alt="Nav Register" border="0"></a><br> <a href="contactus.php"><img src="images/nav_bottom.png" width="232" height="179" alt="Nav Bottom" border="0"><br></a> </div> <div class="cb"> <img src="images/login.png" align="right" class="welcome"> <br> <br> <br> <br> <table width="300px" align="right"> <form action="<?php echo $PHP_SELF; ?>" method="POST"> <tr> <td> <font color="white"> Username: </font> </td> <td> <input type="text" name="username"> </td> </tr> <tr> <td> <font color="white"> Password: </font> </td> <td> <input type="password" name="password"> </td> </tr> <tr> <td> <br> </td> <td> </td> <tr> <td> </td> <td align="right" style="padding-right:8px"> <input type="submit" name="submit" value="Login"align="right"> </td> </tr> </form> </table> <p><?php echo $error; ?></p> </div> </div> </center> </body> </html> Help would be great!
  23. You were right. I didn't have data in the DB properly. Thanks for that.
  24. Yes....you can see it. $amount = $buildinglevel * $gatherers / 4;
×
×
  • 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.