PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
grabber_grabbs wrote:ON the net, they have this example (this is to put some php code in a html document.)
If by "html document" you mean the file is still a .htm or .html file, it won't work. You have to give it a .php extension for Apache to know to actually parse the file as PHP.
So it really works the other way round: you can put HTML in a PHP file.
well, i can try, but most of the code is html....
<html>
<head></head>
<body class="page_bg">
Hello today is <?php echo date('l, F jS, Y'); ?>.
<?php echo "have a nice day"; ?>
</body>
</html>
What do you mean 'why now'? As Apollo explained, Apache needs the .php extension to recognize that the page contains PHP code and have it interpreted accordingly.
thanks for the info.
What puzzle me though is why when someone click on the link i just gave, they see good results, but if i do the same here, it doesnt work
The link you posted there is a .html file. Again, this won't work!
Unless you did some trickery to internally redirect that (using mod_rewrite) to a .php file, or reconfigured Apache to parse .html as PHP well (neither of which is the case), this means your webserver (Apache) will parse it as HTML, not as PHP.
Forget about .htm or .html, just don't use it. Not in filenames, not in links.
The conversation has drifted a bit from this point, but I would recommend not using a database for this - there's no benefit. You don't need to do relational queries, so you don't get any benefit. Since the data isn't really dynamic, there's no point in wasting clock cycles building the page dynamically.
My recommendation would be to stick with importing the CSV, and have your PHP script generate static HTML that you then incorporate into your website.
As your your current problem ~grabber, servers generally only know to parse PHP code if the file ends in .php. If it ends in .html, the server thinks it's just html/text, and sends it to the browser. If it sees .php, it knows it needs to inspect the file & execute any PHP code it finds.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
isnt it easier to import the CSV into the SqL table...then, lots of tools are available to manage the data.... it would also be easier sorting the info and also easier for a search engine to screen data....
If you're doing dynamic things to the info (like sorting & searching), then ya, a database would be best. If you're just showing the information, just stick with the CSV.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.