Re: Viewing a specific item within a php web-page?
| From: | Josip Dzolonga | Date: | Sun, 10 Apr 2005 10:25:04 +0000 |
| Subject: | Re: Viewing a specific item within a php web-page? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-212756@lists.php.net to get a copy of this message | ||
Carlos Palomino wrote:
I have a document entitled: articles.php Within this document, I want to store various written articles which are headed by a string value - example: $post_040905 = "text for April 9th 2005"; print($post_040905); $post_041005 = "article for April 10th 2005"; print($post_041005); That's a _really_ bad idea. It is better to store all of them in a database (MySQL is a simple one and works perfectly with PHP) ordered by an id. So the script can take a numerical argument ID which will hold the ID of the text which shall be shown. The argument can be passed as a GET variable (script.php?variable=value&second=second_value) and you can get it with $_GET['variable_name']. Take a better look here http://www.php.net/manual/en/reserved.variables.php#reserved.variables.get . However don't forget to filter than input argument first, to prevent SQL Injections :$id = $_GET['id']; if($id == strval(intval($id))) { /* Okay, do the query */ } else die('Looser !'); Hope this helps, -- Josip Dzolonga http://josip.dotgeek.org jdzolonga[at]gmail.com