Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender

LittleJoe's Achievements


Newbie (1/7)



  1. Thanks guys, you're the best.
  2. I need to loop through an array, in the order that the items appear, and get both the key of the item and its value. I know I can use foreach to loop through an array but as far as I know I can choose between the key and the value of the current item but not get both. Here's an example of an array: <?php$SampleArray = array(55 => "car","2" => "house","boat" => "boat",0 => "engine",666 => "website",);?> It would work somehow like this: loop($SampleArray){ echo key . " - " value . "n";} And the result would be something like:55 - car 2 - house boat - boat 0 - engine 666 - website
  3. I'm wondering whether the lang attribute applies to the rendered content only or whether it also applies to metadata, comments and code (variable names, CSS id/class names). If my metadata etc is in US English but the rendered content is in French, which is the right way to go? 1) Language declared in the root element and then changed in the body element where the user content is. <!DOCTYPE html><html lang="en-US"> <head> <meta charset="UTF-8"/> <title>Title</title> </head> <body lang="fr"> </body></html> 2) Language for metadata etc declared in the head since that's where the metadata is and then changed in the body element where the user data goes. <!DOCTYPE html><html> <head lang="en-US"> <meta charset="UTF-8"/> <title>Title</title> </head> <body lang="fr"> </body></html> 3) Language declared as French in the root element and metadata language not declared (because it doesn't apply to it). <!DOCTYPE html><html lang="fr"> <head> <meta charset="UTF-8"/> <title>Title</title> </head> <body> </body></html>
  4. I'm talking about storing the JavaScript code inside PHP files (.php) and including it in your HTML/PHP files (include "javascript/menu.php") so that the contents of it appear to belong to the HTML page itself.
  5. I'm thinking about developing a website that will use the following dynamic architecture: index.php?id=1index.php?id=2index.php?id=3index.php?id=4etc. As opposed to the static (old school): index.phppage1.phppage2.phppage3.phppage4.phpetc. What are the pros and cons in terms of caching, search engine indexing and other stuff you can think of?
  6. People always say that if you have JavaScript code which is used by multiple pages then it should be in an external page but if it is only used by a single page in should be internal. People also say that external JavaScript code can make the browsing slower since additional PHP requests are made but that when it is internal less bandwidth is used. Is it a good idea to put JavaScript code into PHP files and then include them like any other PHP files? I've been thinking about this because then I can minimise the HTTP requests and at the same time use the same JavaScript files in many PHP files.
  7. I guess that makes more sense. Thank you guys!
  8. So we are then all in agreement that using a database for this is a no no?
  9. Not every translation in every language is loaded but every translation in the relevant language. Isn't that a bit much?
  10. I'm working on a website that I want to be accessible to speakers of many languages but I'm wondering how to architect such a website. I seem to have two options and I hope you guys can help me choose: 1) Database I could make a table that lists all the messages and then have individual language tables with translations of those messages. Each page would then make a dozen or more queries to get all the messages/content to populate each page. I'm a bit worried about what the effect this may have on my databases and whether it is too much for them to handle in addition to all the other queries such as registration, login etc. 2) PHP array Using PHP arrays is also a popular solution. I think both MediaWiki (which drives Wikipedia etc) and phpMyAdmin go with this solution. It's easier to crowd source the translation this way since most people are familiar with pure text files. I'm worried about all the memory that is consumed by this approach and at what point it becomes inviable since every translation gets loaded into memory for every page request.
  11. I have never installed such chaching technology and don't know much about it. Since I will be making use of shared hosting I will have to see what they offer.
  12. Yes, that did come to mind but I was just hoping there was an easier build-in option.
  13. Well if I'm forced to query the DB on every page then I suppose that's what I must do but I just wanted to see if I could just a session somehow to do it instead and alter the session automatically for that user because I always hear that you should do as few queries to the DB as possible and use sessions instead and doing a query on every page does sound DB consuming.
  14. When a user logs on my site a session variable is created to keep the user id and also whether said user is actually logged in (for those pages that require the user to be logged in to view them). Now, let's say I notice a user misbehaving and I want to kick him/her off or deactivate the user's account, if I stored the login state in the database I would just change the value of in the user's record but since it's in a session variable, how would I go about getting that particular user's session to modify it? I don't want to have to do a database query during every page load to see if an admin has deactivated the account. The only solution I have in my head right now is to manually modify the session file in the temporary directory which is pretty inefficient and hard.
  15. Delete this post.
  • Create New...