Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by trq

  1. Nope. You might have better luck finding a database of postcodes.
  2. trq

    Array Help

    That wasn't necessary and also not the issue.
  3. I should probably post an example: $sql = " SELECT category, COUNT(category) AS cnt, name FROM postlisting LEFT JOIN categories ON (postlisting.category = categories.id) GROUP BY category "; This assumes a new categories table that holds both an id (relating to postlisting) and a name.
  4. I would seriously consider creating a categories table then simply joining on that to get your category names. It would be simple, easier to add new categories and practically zero overhead on your query.
  5. Any data outside of the web server root can not be accessed via the web. Hell, you can even place passwords etc etc inside a php script within the web root and they can't be read unless your script echoing the variables back to the client. This can fall over however if somehow your server becomes misconfigured and starts server php as plain text. All files and directories only need to be read by the web server. Of course, you yourself may need write access to be able to edit the application though this should really be done on a separate dev server and then your application installed into production. Keep in mind that some directories may also need to be writable by the web server if you wish users to be able to upload files etc etc. Most of what I'm covering here is probably a bit over the top for general web sites, and allot of hosts won't even grant you the ability to do allot of what I've mentioned, but I figure your asking the questions so.....
  6. I haven't looked at the code but put simply you would need to insert the required data into the database query.
  7. You can use jsonp if the api provides it. The one your using doesn't appear to.
  8. Any suggestions? You haven't exactly asked a question. Where are you stuck?
  9. From memory this was only ever a netscape issue anyway, so unless your users really are dinosaurs I wouldn't bother.
  10. I think your still misunderstanding what the web root is. My typical structure is (simplified) something like: [pre] project htdocs assets js css imgs .htaccess index.php lib MyFramework [/pre] Where the htdocs directory is configured to be my web servers document root. My framework would then sit within a lib directory completely outside of a position where it is at all accessible via the web. In fact my framework will most often sit in /usr/share/php or some other globally accesible location and I will just add it to my include_path in order to use it. Point being, your php code does not need to be within your web root (only the index.php file which bootstraps the application). That's not to say you have to do it this way, and in fact most people don't or can't because they simply do not have the ability to do so because of there hosting.
  11. This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=342739.0
  12. trq

    Array Help

    function filter_words($text, $data) { foreach($data->words->word as $w) { $text = str_replace(strtolower($w), '[!]', strtolower($text)); } return strtoupper($text); }
  13. $sql = "SELECT category, COUNT(category) AS cnt FROM postlisting GROUP BY category"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo "There are {$row['cnt']} items in {$row['category']}<br />"; } } }
  14. Sorry, but that is probably some of the worst code I have ever seen. You can use one query and simply GROUP BY category.
  15. There is only a single call to mail() in the code you have posted.
  16. trq

    Array Help

    Put return after the loop.
  17. trq

    Array Help

    return exits a function when it is executed, so your loop will only execute once, then exit.
  18. This is not a coding issue but a configuration issue. I would speak to whomever maintains the mail server.
  19. Do you have a mail server installed and configured?
  20. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=342726.0
  21. The thing that stands out the most is that your client side stuff is mixed in with your server side stuff. I would be inclined to make a new directory and place all your js, css and images within there own sub directories within that. Then, if your have sufficient privileges to do so your could (and should) also make this your servers document root for this site.
  22. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=342727.0
  23. Have you tried Googling for a tutorial?
  24. return exits a function and returns it's argument.
  25. This sounds like it would perfectly suite an ajax solution, something like what Facebook and Twitter do where as you forreach near the end of the page more data is dynamically fetched. Getting everything up front seems a massive waste of resources.
×
×
  • 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.