PHP - Initial Steps Of A 'on This Day In History' Script
A friend of mine is looking at relaunching a site he used to run and I am going to try to persuade him to move over to a dynamic site.
The site is a Football Clubs history site and contains around 2,000 games and several hundred players. The obvious advantage of a dynamic site is that even the bits I just mentioned run to around 2,500 static pages, which could be reduced to just 2 pages if dynamically driven. I am fairly confident that I can do the conversion, but there is one thing that I already know I may struggle with and that is the page which shows game, births and deaths on this day in history. A rough example (using a very heavy Javascript code) can be found at http://follyball.co.uk/jeff/. In a simplified form (ignoring for now the foreign keys to relationships that these tables actually have) there will be two tables GAMES game_id | date | competition | opponent | score | attendance PLAYERS player_id | surname | firstname | date of birth | date of death What I would be looking for is a way to take todays date, and find any corresponding records in games.date, players.date of birth, players.date of death on the same date in previous years. This would be simple to do as three different queries but as I would like to actually mix the three and show them in date order, I would like to do it in one query, presumably using UNIONS. On top of this, I would also like a slightly different output for each different set, for example, if it was a game I would like year, competition, opponent, score, attendance, Whereas if it is a players birth or death, I would like it to show something like firstname surname was born in year Before I go delving too deep into how it may be done, I would like to know if it can be done! I cannot see why it would not be able to generate this but if it is going to be way out of my ability, then I will look for another option! Thanks in advance Steve Similar TutorialsI am creating an add on to a 3rd party CMS called Concrete5. Normally, when I have client issues, I can trace them to the server and fix them, however, this not doing so well on these issues. The following errors are being displayed in Chrome console:
Checking the server’s folder directory, it is true there is no concrete/fonts directory but there is a concrete/css/fonts directory with a couple of the missing files (but not glyphiconshalflings-regular.woff2).
Back to the errors, clicking the line number (i.e. 927, 3115, and 1), chrome blames apparently innocent line numbers.
What steps would you recommend taking to identify the cause and fix these errors? I've been looking for one all over the internet and have yet to find one to my exact specifications. I don't even know how I would attempt to make said script since I don't have a database of my own with that type of information stored on it. I basically want to use History.com's This Day In History feed on my website, but I don't like their RSS feed considering it's a giant paragraph of a single article. I'm just looking to post a few random dates and some information like this for example: 1986 > blah blah blah 1990 > blah blah blah 2010 > blah blah blah Any help would be greatly appreciated brethren. Hi all, I am sure this is simple, but I just can't wrap my head around a suitable way of doing this! Basically I have my JSON result as something like : Code: [Select] Array ( [result] => success [source] => gotBits [success] => 64 ) What I simply want to do is get the [success] output and store it as a variable. I have been looking at json_decode, but I cant find any examples for arrays, just strings? Can you push me in the right direction? So I've recently started looking into Character Encoding, after never really bothering with it, and I've got a few questions. After checking out my site it seems I've been using UTF-8 without really realising it, and I'm going to stick with UTF-8. However, when I jump into phpMyAdmin to check out my MySQL tables I run into a few problems. Originally, for my database, the collation was set to latin1_swedish_ci. I have since changed this to utf8_general_ci. This however only affects newly created tables, not the 150 or so tables I currently have which are still latin1_swedish_ci. Do I need to convert the collation of these already existing tables to UTF-8, and if so what's the best method? This takes me to my text editor, NetBeans 7. Do I need to alter anything here, I've not been successful with finding information relating to this? Cheers guys. i am trying to make a range of numbers which have a step of 11 then 7 then 11 which can then be compared. the result im after is 1, 12, 19, 30. Is there a way i could do this without storing the sets in an array and looping though them? Any help would be greatly appreciated, thanks. Hello guys. I'm in need of help. I want to know who to make a full working session. When a player logs in, the session starts. There will be a new button "My Page", he can go there at any time. When he logs off, that button disappears ( Session over ). I'm so bad at explaining stuff. Hope y'all really understood me. This piece of code is used to log the user in: Code: [Select] <?php session_start(); include("config.php"); if(isset($_SESSION["Username"])) { $user = $_SESSION["Username"]; $pass = md5($_SESSION["Password"]); } else { $user = $_POST["User"]; $pass = md5($_POST["Password"]); $_SESSION['Username'] = $user; $_SESSION['Password'] = $pass; $escuser = mysql_real_escape_string($user); $escpass = mysql_real_escape_string($pass); } $result = mysql_query("SELECT * FROM playerinfo WHERE user = '$escuser'"); $num_rows = mysql_num_rows($result); if($num_rows == 0) { echo('That username does not exist...'); echo '<a href="http://yu-ki-ko.com/fsns/""> Go back!</a>'; unset($_SESSION['Username']); unset($_SESSION['Password']); die; } $row = mysql_fetch_row($result); if($row[1] !== $escpass) { echo('Wrong Password!...'); echo '<a href="http://yu-ki-ko.com/fsns/""> Go Back!</a>'; unset($_SESSION['Username']); unset($_SESSION['Password']); die; } ?> Not sure if its working properly or not. I'm stuck at that part. Okay, here's what I'm doing. It's sort of like a market script. When someone wants to buy something, they choose from a drop down the item they wish to buy. However, there is a setup cost for it to be started. Then, based upon the length they choose (anywhere from 1 - 12 months), the cost will add up. My questions a Is it possible to assign a setup cost? How can I make it so that, while some things will be, say $2 a month, others will be $3 or other amounts? Here's what I have so far, to try and figure this out. Feel free to laugh... Or if you could point me to an example of something like this, I'd be very appreciative! Thanks!! function ChangeInitialCost(){ $cic = ($_POST['newpremium']); if (($cic == "clan") || ($cic == "guild") || ($cic == "house") || ($cic == "militia")){ } And the form I have: (I haven't entered a submit button yet...) Code: [Select] <table width="200" border="1"> <form action="premium.php" method="post" name="purchase"> <tr> <td>Premium:</td> <td><select id="newpremium" name="newpremium"> <option value="casino">Casino</option> <option value="clan">Clan</option> <option value="guild">Guild</option> <option value="house">House</option> <option value="militia">Militia</option> </select></td></form> </tr> <tr><form action="premium.php" method="post" name="length"> <td>Length:</td> <td><select id="length" name="length"> <option value="0">-----</option> <option value="1">One Month</option> <option value="2">Two Months</option> <option value="3">Three Months</option> <option value="4">Four Months</option> <option value="5">Five Months</option> <option value="6">Six Months</option> <option value="7">Seven Months</option> <option value="8">Eight Months</option> <option value="9">Nine Months</option> <option value="10">Ten Months</option> <option value="11">Eleven Months</option> <option value="12">Twelve Months</option> </select></td></form> </tr> <tr> <td>Cost:</td> <td>SOME TYPE OF FUNCTION</td> </table> I'm trying to get a count of how many topics someone starts in a forum. I use XenForo, and they only count Posts, but I can order Posts by post_id and group those posts by thread_id to determine the initial instance of that topic. The problem I'm having is output. I'm getting the right User info, but the output is offset by one row: User 1 | 0 topics (because $c=0) User 2 | 128 topics (but those are User 1's #) User 3 | 0 topics (but those are User 2's #) User 4 | 141 topics (but those are User 3's #) etc
I realize as I play through the logic of the code, it's printing in that order. I can't seem to get the right order. I've tried various ways, with a couple of extra IF statements in there too.
$query = "select thread_id,user_id,username from ( select * from xf_post order by post_id ) x group by thread_id order by username,thread_id"; $results = mysqli_query($con,$query); echo mysqli_error($con); $c=0; $currentID = false; while($line = mysqli_fetch_assoc($results)) { if ($currentID != $line['user_id']) { echo '<div>' . $line['username'] . ', ' . $c; $currentID = $line['user_id']; $c=0; } else { $c++; } }
I am trying to initialize every value in my $errors array to have a value of '' so I don't get "undefined variable" errors! Here is what I have... Code: [Select] //Put in some values and then try to erase them. $errors = array('firstName' => 'Enter First Name', 'lastName' => 'Enter Last Name'); //Want an initialized array. foreach($errors as $key => $value){ $key = ''; } But that doesn't seem to work when I run Code: [Select] print_r($errors, true); Thanks, Debbie Is this the correct syntax to check for an optional Middle Initial... Quote if (preg_match('/^?[A-Z]$/i', $_POST['middleInitial'])){ Thanks, Debbie Hi! Having a lot of fun dusting off the coding and putting together a site with PHP, CSS, and jQuery. I've run into one problem that I can't get past though. I implemented jQuery History to use hashtags to maintain browser back/forward buttons and linkability of the site (and not reload header and footer when updating content). The main purpose of the site is to showcase photography that's hosted on Flickr. I've got this working well using Slickr. I have the Slickr code to load my galleries sets in a file called 'pictures.php' which is loaded fine into #page_content using a link to #pictures. The problem arises when I click on a gallery/set: I get taken back to the default view of the site without any hashtage because Slickr requires a link using parameters, so: www.myexamplesite.com/#pictures becomes www.myexamplesite.com/index.php?id=72157626067797650&p=1 As you can see, since it loses the hashtag, I am no longer looking at the right page. Does anybody have any ideas on how I can specify both the hashtag and the parameter? Cheers! This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=353212.0 Hi my website has been working all day now everypage is getting this error also get the same error when i try to login into phpmyadmin Lost connection to MySQL server at 'reading initial communication packet', system error: 111 is this most likely a problem with the server? I have the below code to open contents in a div or modal window and at the same time showing the url that matches the specified page which works as expected, no problems rising:
$(document).ready(function(){ ///////LINK in a Div//////// $('#all').delegate('a.img-lnk, a.txt-lnk', 'click', function(){ $('#main').empty(); var page = $(this).attr('id'); var pageurl = $(this).attr('data-seo'); $('#main').load("../"+ page + ".php"); window.history.pushState('','',pageurl); }); ///////LINK in a Modal Window//////// $('#all').delegate('a.pop-lnk', 'click', function(){ var poppage = $(this).attr('id'); var popurl = $(this).attr('data-seo'); $('#popup').load("../char-inf/"+ poppage + ".php"); window.history.pushState('','',"/char-inf/"+ popurl); }); $('body').delegate('.hide-it', 'click', function(){ $('.hide-it').hide(); $('#popup').empty(); window.history.back(); }); });Problem: If I give you a url of a link in my page e.g. www.example.com/test1 and paste it in your browser the test1 page will open normally, BUT after that if you navigate to page test2 then the new url becomes www.example.com/test1/test2. Is there a way to turn the url at its normal state which would be www.example.com/test2? Customers can view transaction history for approved and declined transactions (the reason for the decline should be included). Transactions are logged with their transaction reference numbers and status. hello guys, this is my first post on this forum and I really need your help on this. What I have is: I created a login page a home page and a index page. The index page checks if the session is set. If it's not the login page will be shown. If it is the homepage will be shown. Whenever the user logs in, the session gets set. The problem is is that whenever I login and the user presses the back button on his browser my session will always be returned false which means that whenever a user has logged in, the index page doesn't show home but shows the login page again even though the user has already logged in. Here is my code to make you understand a little bit better: session.php: Code: [Select] <?php class Session { function __construct() { } function set($name, $value) { $_SESSION[$name] = $value; } function get($name) { return $_SESSION[$name]; } function stopSession() { unset($_SESSION); session_destroy(); } function startSession() { if(!isset($_SESSION)) { session_start(); } } function check_session() { if(isset($_SESSION['username']) && !empty($_SESSION['username'])) { return true; } else { return false; } } } ?> login.php: Code: [Select] <?php class Handler_Login extends Action_Handler { function __construct($action_handle) { parent::construct($action_handle); $this->action = $action_handle; } function secured_handler() { $password = $_POST['password']; $username = $_POST['username']; $login = $this->dbh->Login($username, $password); if ($login == true) { $this->session->startSession(); $this->session->set('username', $username); $this->view->displayHome(); $this->view->display(); } else { //This is going to get more advanced later on, I'm currently working on resolving my session issue before I continue on this. echo "you are not logged in"; } } } ?> index.php: Code: [Select] <?php class Handler_home extends Action_Handler { public function __construct($action_handle) { parent::construct($action_handle); $this->action = $action_handle; } function secured_handler() { // for some reason this always returns false when the user goes back in history :( if ($this->session->check_session() == false) { $this->view->displayLogin(); $this->view->display(); } else { $this->view->displayHome(); $this->view->display(); } } } ?> anyone has an idea why the login page is always shown ? Is there a way to change the url in the code below using window.history.pushState dynamically to match the "page" variable?
$(document).ready(function(){ $('#all').delegate('a.pop-lnk', 'click', function(){ var page = $(this).attr('id'); $('#popup').load("../folder/"+ page + ".php"); window.history.pushState('','','/page'); }); }); Edited by Pavlos1316, 18 November 2014 - 03:58 PM. Dear fourm, i am wondering if anyone can shed some light on this form submission problem with back/forward buttons. long story short: i used to make a form, then submit to a form process php file. errors were difficult to deal with. Thus, many people tell me to submit to the same page. I now submit to the same page. my homepage has a login button. i use a csrf token in a hidden input matched with a session variable. i decided to submit to same page and handle the submit like so: if server request-method = post and isset input name and isset session token then check the token with hash_equals if everything matches then show the login page. i don't have a problem with the form and the form submission processing. everything i fine. now when i use the browser refresh button on the login page, i am sent back to the homepage. all is good. when i press the back button, i go back to the homepage again. super. then i press the forward button in the browser and i get a not connected error. the back button now also shows this error. i tinkered around a bit and added crazy ideas and it worked one time with unset($_POST) as an else to the if mentioned above. the idea is that if server request-method is post without an else. the page is listed below for any get request to process. i assume that the browser is trying to repost data is empty but my if statement should kick it out to the get code, right? what i want is to unset the csrf token and the matching session token for security purposes. i suppose that this breaks the back/forward buttons? how can i get the browser to show the homepage regardless of the post situation? there must be a logical answer. something in my code is breaking this an preventing the browser from simply loading the home page any help is greatly appreciated! Thank you. Like many parents, I'm challenged with keeping my kids from browsing the evil parts of the internet. My son is 11 and my wife caught him deleting IE history the other day. The computer he uses is a Windows 8.1 laptop, and it is not Pro. How can i let him use internet explorer on his own user but keep him from tampering with any of the history ( or settings for that matter)? Is there a better solution? I found some internet history logging software online, but I didn't feel comfortable with the source, and fear it may contain viruses or other malware. I am trying to create a order history page. I want it to look something like this: Ordernumber: 12 Products: Product 1 Product 2 Product 3 Product 4 Total: xx Ordernumber: 13 Products: Product 5 Product 6 Total: xx and so on. I have a recordset which get the ordernumbers from my database and i have another recordset which get the products (this recordset has a WHERE clause which is used to get the products associated with its ordernumber. Code: [Select] mysql_select_db($database_lol, $lol); $query_ono = "SELECT DISTINCT ordre.ono FROM ordre WHERE ordre.bruker='{$_SESSION['MM_Username']}'"; $ono = mysql_query($query_ono, $lol) or die(mysql_error()); $row_ono = mysql_fetch_assoc($ono); $totalRows_ono = mysql_num_rows($ono); mysql_select_db($database_lol, $lol); $query_history = "SELECT ordre.vare FROM ordre WHERE ordre.ono='{$row_ono['ono']}'"; $history = mysql_query($query_history, $lol) or die(mysql_error()); $row_history = mysql_fetch_assoc($history); $totalRows_history = mysql_num_rows($history); This is the recordsets. this is my table: +-------+---------------------+------+ | ID | vare | ono | +-------+---------------------+------+ | 1 | Product 1 | 12 | | 2 | Product 2 | 12 | | 3 | Product 3 | 12 | | 4 | Product 4 | 12 | | 5 | Product 5 | 13 | | 6 | Product 6 | 13 | +-------+---------------------+------+ So my question is: How do i do this? list all the records i mean. Thanks |