Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 09 Aug 2013
Offline Last Active Sep 01 2013 05:33 PM

Topics I've Started

Subtract timestamp time from current time

01 September 2013 - 02:09 PM

I want to subtract database timestamp from current server time. The formatted time that is returned to me from my database is "2013-09-01 22:05:39" and I use function date("Y-m-d H:i:s"); so that my server time I get in php is in the same format.


How can I get a result in hours? Example: 2013-09-01 22:05:39  minus 2013-09-02 22:05:39 equals 24 hours ???

Display database rows in html by id

25 August 2013 - 02:47 PM

Hey, I want to list all of my database entries to a nice html format. For every unique id there is one row displayed out from my database to my php/html. I just don't know how to do that. I tried using while loop and foreach I just don't know how to properly structure them... My query and php code looks like this:

$query = mysql_query("SELECT * FROM sport");

while($row = mysql_fetch_array($query))
    $result = $row['sport_ime'].' '.$row['sezona'];

How to recognize original redirection document

24 August 2013 - 04:20 PM

Lets say I have a form in form.php and when I click submit all inputted data is sent to model.php for database manipulation etc.. and then when everything is done the model.php redirects user back to form.php using function:


How in the blazing hell can form.php recognize I was redirected there from model.php ? I am so lost about this for so long now, I tried $_SERVER['HTTP_REFERER'] and everything and I just get an echo with my current page location. I want to get an echo of the model.php on my form.php


Website server directory access

13 August 2013 - 02:02 PM

I am curious about server access. Lets say you buy a hosting service, can you manually decide which directories will be public and which will be off limits? Do public directories have to include views (templates)? Because in a lot of frameworks I see views in private directories. Can you block access via .htaccess and only allow users to browse certain pages? How do you prevent them from browsing your entire php app files?


I know this is a lot of question but a simple overview about directory structure in apache servers will do, since I am building one.

Front controller for the entire site, or more smaller ones?

13 August 2013 - 11:23 AM

Hey, I was asking a lot of questions lately on this forum and it all boiled down to this one. We all know it is hype to implement front controller or master page index.php that handles all the requests to all the pages and reroutes you etc... All this for cleaner urls, easier code handling...


But what if you have a browser game with a lot of locations and variables, states, conditions etc.. I can't write a million if statements or switch statements on my index page. What if I implement such page structure as described below? Basicly you don't have single point of entry or one front controller but more main controllers that connect to subcontrollers:

                                                                  if location forest
                     if loged in                             |---------------------------- forest.php
                  |------------------ start.php -------------|
                  |                                          |    if location home
                  |                                          |-------------------------- homebase.php
                  |                                          |   
                  |                                          |    if location else
index.php---------|                                          |------------------------- anywhere.php
                  |  if in fight
                  |------------------- combat.php
                  |  if not loged in
                  |------------------- homepage.php

Why would all pages have to go through index.php? This would be a big mess! Divide pages based on location, for example my start.php page will decide where to redirect further. So in this case I have two bigger controllers not just one front one. Is this still a good convention? I mean is this still a good front controll design or is it better to leave all the redirects to index.php?