Jump to content

radiohomer

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

radiohomer's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. man you are the best i thank you sooo much for everything i will learn this one day
  2. that is perfect im so grateful thank you one last question is there any way to only show 5 results? if not dont worry about it
  3. its still showing them in the wrong order its showing the newest at the bottom
  4. ok so this is the code that im now using from the code generator i have added the field "datetime" to the database and removed all the single time and date fields this is the code i use to add things to the database <form id="FormName" action="added.php" method="post" name="FormName"> <table width="448" border="0" cellspacing="2" cellpadding="0"> <tr> <td><input id="new_news_date" name="new_news_date" type="text" size="25" value="" maxlength="255"></td> </tr> <tr> <td><textarea id="new_news" name="new_news" rows="4" cols="40"></textarea></td> </tr> <tr> <td><input type="submit" name="submitButtonName" value="Add"></td> </tr> </table> </form> then i click on submit and it sends the data to this page <?php include("connect.php"); $new_news_date = trim($_POST['new_news_date']); $new_news = trim($_POST['new_news']); $query = "INSERT INTO new_news (id, new_news_date, new_news) VALUES ('', '$new_news_date', '$new_news')"; $results = mysql_query($query); if ($results) { echo "Details added."; } mysql_close(); ?> the index page which displays all the data is this code <?php include("connect.php"); $query = "SELECT * FROM new_news "; $result = mysql_query($query); $num = mysql_num_rows ($result); mysql_close(); if ($num > 0 ) { $i=0; while ($i < $num) { $new_news_date = mysql_result($result,$i,"new_news_date"); $new_news = mysql_result($result,$i,"new_news"); $id = mysql_result($result,$i,"id"); echo "<b>new_news_date:</b> $new_news_date<br>"; echo "<b>new_news:</b> $new_news<br>"; echo "<br><br>"; ++$i; } } else { echo "Sorry No News"; }?> and here is the sql query CREATE TABLE `new_news` ( `id` int(6) NOT NULL auto_increment, `new_news_date` datetime NOT NULL default '0000-00-00 00:00:00', `new_news` text NOT NULL default '', PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) if there is anything else you need Pikachu2000 let me know again i really appreciate your help
  5. The two entries in there are only test data, i will be entering data through a different form
  6. Ok thank you, i will wait till your next reply, also if i dont reply its because my isp has gone down, i dont even have a dial tone on my phone line, im having to use my mobile to reply, Again thank you for helping me
  7. please if you would be so kind to help i will be VERY great full here is the website i used to get the code http://www.turningturnip.co.uk/free-mysql-php-generator/web-code-creator.php
  8. to be totally honest... i used a code generator to give me that code and its working perfect apart from its showing the old at the top and the new at the bottom
  9. hey guys i have this code below that grabs the data from the database <?php include("connect.php"); $query = "SELECT * FROM new_news "; $result = mysql_query($query); $num = mysql_num_rows ($result); mysql_close(); if ($num > 0 ) { $i=0; while ($i < $num) { $new_news_day = mysql_result($result,$i,"new_news_day"); $new_news_month = mysql_result($result,$i,"new_news_month"); $new_news_year = mysql_result($result,$i,"new_news_year"); $new_news_hour = mysql_result($result,$i,"new_news_hour"); $new_news_minute = mysql_result($result,$i,"new_news_minute"); $new_news_am_pm = mysql_result($result,$i,"new_news_am_pm"); $new_news = mysql_result($result,$i,"new_news"); $id = mysql_result($result,$i,"id"); echo "$new_news_day "; echo "$new_news_month "; echo "$new_news_year - "; echo "$new_news_hour:"; echo "$new_news_minute "; echo "$new_news_am_pm<br>"; echo "$new_news"; echo "<br><br>"; ++$i; } } else { echo "No News"; }?> here is the database structure with 2 test entries (please note that there will be more than 2 entries, the code is looped so it will repeat the output) they are sorted via ID here is a basic layout of the database ID new_news_day new_news_month new_news_year new_news_hour new_news_minute new_news_am_pm new_news 1 8th June 2011 10 32 am Testing the news. 2 9th June 2011 2 15 pm Testing the news again. now when it shows on the page its shown like this 8th June 2011 - 10:32 am Testing the news. 9th June 2011 - 2:15 pm Testing the news again. everything works and connects ok ect ect BUT as you can see by the PHP code above it gets the data from the database and repeats to display all the data in the database so if there is only one entry it will only show one entry if there were 200 entries it will show all 200 entries now as you see the code is arranging them in order oldest at the top and newest at the bottom... is there any way to change the code so it shows the newest at the top and oldest at the bottom?? hope people can understand what im after in short the code is showing this 8th June 2011 - 10:32 am Testing the news. 9th June 2011 - 2:15 pm Testing the news again. i want it to show this 9th June 2011 - 2:15 pm Testing the news again. 8th June 2011 - 10:32 am Testing the news. thanks guys
  10. thanks for your input Fugix i have just tried that and it didnt work i have found a different way to do this my whole reason for the code above was because index.php has 3 frames on there and whenever i clicked a link it just opened in that frame and left the rest showing the content from index.php i never thought to use parent.top or target="_top" here is the code i have used and have got working <select> <option>--Choose--</option> <option onclick=parent.top.location="index.php">Index</option> <option onclick=parent.top.location="page1.php">Page 1</option> </select> this gets rid of the frames on the index page and loads page1.php in the full view
  11. ok so its as the title says is there a way to open a new window and close the old one? ok so ill explain a little more on what i want to achieve i have 2 pages index.php page1.php on the index.php page i have a dropdown box with 3 options <select> <option>--Choose--</option> <option onclick="window.open('index.php')">Index</option> <option onclick="window.open('page1.php')">Page 1</option> </select> ok so the dropdown box is doing what i would like by opening a new window but i would like to close the old one. at the moment this is whats happening the user is viewing "index.php" he clicks on the dropdown and selects "Page 1" this opens a new window displaying the content of page1.php but the index.php page is still open. this is what i would like to happen the user is viewing "index.php" he clicks on the dropdown and selects "Page 1" this opens a new window displaying the content of page1.php and also closes index.php. is this possible?? i just cant get it to work... i have seen it done before but cant find the website that i saw it on i have tried using onclick, onchange ect ect if anyone could help me with this that would be great
  12. managed to get it working thanks for the help guys
  13. cant get that working where ever i put it and what ever i do with it
  14. im not fussed on authenticating ect the website is on a local network and not open to the WWW the code is so a select few of the users can access other area's but im wanting this to run off a DB if someone could edit / change the code below to allow it to GET the data from the database that would be great im not bothered about a registration page or anything i just want the code below to connect to the DB so it can login the right user if that makes sense... <?php /* $LOGIN_INFORMATION = array( 'test' => 'testpass', 'admin' => 'passwd' ); <?php include("password_protect.php"); ?> logout link http://www.example.com/path/to/protected/page.php?logout=1 */ ################################################################## # SETTINGS START ################################################################## // Add login/password pairs below, like described above $LOGIN_INFORMATION = array( 'test' => 'testpass', 'admin' => 'passwd' ); // NOTE: all rows except last must have comma "," at the end of line // request login? true - show login and password boxes, false - password box only define('USE_USERNAME', true); // User will be redirected to this page after logout define('LOGOUT_URL', '/'); // time out after NN seconds of inactivity. Set to 0 to not timeout define('TIMEOUT_MINUTES', 1800); // 1m = 60 // 5m = 300 // 10m = 600 // 15m = 900 // 20m = 1200 // 30m = 1800 // 60m = 3600 // This parameter is only useful when TIMEOUT_MINUTES is not zero // true - timeout time from last activity, false - timeout time from login define('TIMEOUT_CHECK_ACTIVITY', true); ################################################################## # SETTINGS END ################################################################## /////////////////////////////////////////////////////// // do not change code below /////////////////////////////////////////////////////// // timeout in seconds $timeout = (TIMEOUT_MINUTES == 0 ? 0 : time() + TIMEOUT_MINUTES ); // logout? if(isset($_GET['logout'])) { setcookie("verify", '', $timeout, '/'); // clear password; header('Location: ' . LOGOUT_URL); exit(); } if(!function_exists('showLoginPasswordProtect')) { // show login form function showLoginPasswordProtect($error_msg) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="robots" content="noindex, nofollow"> <title>login</title> <link rel="stylesheet" href="index_files/style_optimized.css" type="text/css"> <!--[if IE]> <style type="text/css"> #mid{ height:300px; } </style> <![endif]--> <meta name="robots" content="noindex, nofollow"> </head><body> <div id="wrap"> <div id="top"></div> <div id="mid" style="height:auto"> <div id="content-wrap" align="center"> <form method="post"> <table class="login" cellpadding="0" cellspacing="0" width="200px"> <tbody><tr> <td colspan="2" align="left"><strong><font size="+1">Login</font></strong></td> </tr> <tr> <td class="login_lines">Username </td> <td class="login_lines"><input type="text" name="access_login" /><br /></td> </tr> <tr class="row2"> <td class="login_lines">Password </td> <td class="login_lines"><input type="password" name="access_password" /></td> </tr> <tr> <td colspan="2" style="text-align: center;"><input value="Login" class="input-button" tabindex="3" type="submit"></td> </tr> </tbody></table> </form><br /> <script type="text/javascript"> //<![CDATA[ document.getElementById("user").focus(); //]]> </script> <br><br></div> </div> <div id="bot"> </div> </div> </body></html> <?php // stop at this point die(); } } // user provided password if (isset($_POST['access_password'])) { $login = isset($_POST['access_login']) ? $_POST['access_login'] : ''; $pass = $_POST['access_password']; if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION) || (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) ) ) { showLoginPasswordProtect("Incorrect password."); } else { // set cookie if password was validated setcookie("verify", ($login.'%'.$pass), $timeout, '/'); // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed // So need to clear password protector variables unset($_POST['access_login']); unset($_POST['access_password']); unset($_POST['Submit']); } } else { // check if password cookie is set if (!isset($_COOKIE['verify'])) { showLoginPasswordProtect(""); } // check if cookie is good $found = false; foreach($LOGIN_INFORMATION as $key=>$val) { $lp = (USE_USERNAME ? $key : '') .'%'.$val; if ($_COOKIE['verify'] == ($lp)) { $found = true; // prolong timeout if (TIMEOUT_CHECK_ACTIVITY) { setcookie("verify", ($lp), $timeout, '/'); } break; } } if (!$found) { showLoginPasswordProtect(""); } } ?>
×
×
  • 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.