Jump to content

Matic

Members
  • Posts

    42
  • Joined

  • Last visited

Everything posted by Matic

  1. Oh sorry looks like you get the correct result! Thanks for help!
  2. great, I get the part where you convert to strtotime format which is the number of seconds since January 1 1970 00:00:00 UTC etc... Then you divide by 3600 to get hours... Problem is I don't know hot to convert this to my subtracted result back... As it is now, it only shows the hours since January 1 1970 00:00:00...
  3. OK I solved my problem like this: $current_time = date_create(date("Y-m-d H:i:s")); $last_time = date_create(date("Y-m-d H:i:s", strtotime(get_last_update_time($user_name)))); $result = date_diff($current_time, $last_time); echo $result->format('%Y-%m-%d %H:%i:%s'); but it echoes my result like so: "00-0-0 03:40:56", with all the days etc.. How do I format this so that it only show hours, lets say like so: "232156". With all the days, months years, formatted to hours?
  4. Thing is when I convert both formats with strtotime(); and then substract those values the result is off
  5. 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 ???
  6. Thank you so much!
  7. yes this! Now how do I do this properly with foreach statement? This is what I am asking this whole time, though other answers in this thread helped me greatly also
  8. Thanks for all the help but my session variable still shows only the last element of my row. When it is echoes directly it is okay but when it is stored in session it only displays the last element of array... I make my session variable store array like so: $outputs = array(); while($row = mysql_fetch_array($query)) { $_SESSION['row_id'] = $row['id']; $outputs = $row['sport_ime'].' '.$row['sezona'].'<a href=../view/modifikacije.php> Edit</a><br>'; $_SESSION['output'] = $outputs; } and then on another page I call that variable like so: $outputs = $_SESSION['output']; echo ($outputs); It just echoes one row! It is the last entry in my database, why doesn't it want to echo everything? People at another site say that I am repeatedly overwriting the same variables! But I don't know how to avoid that
  9. Well yes I echo in my html file like so: <?php echo($_SESSION['result']); ?> in my backend php I do the session storage like so: while($row = mysql_fetch_array($query)) { $_SESSION['result'] = $row['sport_ime'].' '.$row['sezona'].'<br>'; } // and then redirect back to html where it should echo the stuff header('Location:../view/vnos.php',true,303); exit; The results you requested were just array => 0 and 1 for the last element in my array
  10. That is all fine and dandy but if I call this session in another file and try to echo it, it still displays only the last element of the array...
  11. wow jcbones, is that the code for the entire page?
  12. Oh damn I didn't see that break tag there, my bad! Would you also be so kind to post a solution, if you know one, how to make every row clickable so that user can access entries and modify/delete them? Also does anyone know how to store that line echo $row['sport_ime'].' '.$row['sezona'].'<br>'; inside $_SESSION variable correctly?
  13. no no, echo row just lists entire database in one row like so: "foo1988bar2000etc..." I want each new id in a new row ... I know there is something with for each() statement I just can't format it right
  14. 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']; }
  15. 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: header('Location:form.php'); 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
  16. Great, I thought something was not right here So let me get this, using so called "front controller" in my case doesn't have to do nothing else but "center the logic required to redirect the user to the correct page" ?? Or maybe to make nicer URLs and code editing, since everything will be included from www.index.php/ forward.. It is still a nice practice and a feature to have right?
  17. Thanks for the answers, they raise another question though. How do you make a root directory? Isn't the place you get with the server always the "root"? Or can you access diferent folders on a bought server?
  18. So I guess this logic works like that, it expands outward. However I really don't want to overcomplicate things for now and just use includes and if statements. Your arrays are fine though but atm I have problems understanding nested stuff, I will however do it in the future. But would I also be with the same result if I used includes like I described above?
  19. But the public directories must contain controllers then, or some sort of web pages to view? Because if it doesn't matter, what is stopping me from throwing everything in the private file and never worry about security?
  20. Here is an idea, if you use includes to show pages on index.php right? Those included pages can also have includes of other pages! So in reality you get a tree like hierchy, pages you included under certain circumstances, include other pages in certain circumstances, etc... Am I right here, or this is nothing like that?
  21. 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.
  22. 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?
  23. 1. How else am I supposed to tell the controller and the view to only show information if the user didn't or did click post button on my form? 2. Model issued a redirect because it is wise to implement post-redirect-get pattern, without it my user could just click refresh endlesly and the database would have duplicate entries... Is there any way around this?
  24. If my users have an active session I can also determine which page to redirect them to based on their choices. Just store their actions in a variable and call that variable in index.php And the index.php will display apropriate include file! The url will then always be index.php/
  25. I mean if my user logs i don't have to check $_SERVER request uri etc... I can simply check their requests by $_SESSION variable... And design their front controller acordingly. Right?
×
×
  • 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.