Re: [PHP] Viewing a specific item within a php web-page?

2005-04-10 Thread Prathaban Mookiah
I think you have totally got it wrong. You pass on the value to a php script 
in the form on http://   /script.php?variable=value.

So to accomplish your need you may have to do something like call http://   
/script.php?articleid=post_040905.

Your program should be modified to maybe something like:

?

$post_041005 = article for April 10th 2005;
$post_040905 = text for April 9th 2005;

switch ($_HTTP_GET_VARS['articleid'])
{
   case post_041005: print($post_041005);
   break;
   case post_040905: print($post_040905);
   break;
   default: echo No articleid specified
}

If you still want to call it in the form domain.com/articles.php?post_040905, 
then you may do something like this:

$post_041005 = article for April 10th 2005;
if isset($_HTTP_GET_VARS['post_041005'])
print($post_041005);

$post_040905 = text for April 9th 2005;
if isset($_HTTP_GET_VARS['post_040905'])
print($post_post_040905);

?

There are more efficient ways to do it, but this should get the job done.

Prathap

-- Original Message ---
From: Carlos Palomino [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Sat, 9 Apr 2005 21:23:06 -0400
Subject: [PHP] Viewing a specific item within a php web-page?

 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);
 
 How can I view a specific string's text via the browser?  I thought 
 I could use domain.com/articles.php?post_040905  and only the 
 content written for that post would be shown.  However, all of the 
 posts are shown. I just began reading about PHP from limited 
 tutorials so I am at a loss as to how I can accomplish this.  I 
 would appreciate all assistance in this matter.
 
 Best Regards,
 
 Carlos
--- End of Original Message ---

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Viewing a specific item within a php web-page?

2005-04-10 Thread Josip Dzolonga
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=valuesecond=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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Viewing a specific item within a php web-page?

2005-04-10 Thread Prathaban Mookiah
I guess I had some 'spelling mistakes' in my suggested code.

Try the one below. It should be $HTTP_GET_VARS not $_HTTP_GET_VARS.

?

 $post_041005 = article for April 10th 2005;
 $post_040905 = text for April 9th 2005;

 switch ($HTTP_GET_VARS['articleid'])
 {
case post_041005: print($post_041005);
break;
case post_040905: print($post_040905);
break;
default: echo No article was specified.;
 }

?

And you can name the script in any way you want to. It need not be script.php. 
Say if you put this code into a script call getarticle.php, you should call it 
as youdomain/getarticle.php?articleid=post_x where  is the appropriate 
article number.

As someone else suggested, putting them into a database is the best way to do 
it. But since I guess you are a beginner you might as well keep it very simple 
like this for the time being. But ultimately you should consider databases.

Cheers,

Prathap

-- Original Message ---
From: Carlos Palomino [EMAIL PROTECTED]
To: Prathaban Mookiah [EMAIL PROTECTED]
Sent: Sun, 10 Apr 2005 06:09:53 -0400
Subject: Re: [PHP] Viewing a specific item within a php web-page?

 Hi,
 
 I tried the following but can not view the specified article but 
 receive the default message when attempting to view either of the 
 posts.  I used the proper URL as suggested 
 (script.php?read=post_041005).
 
 $post_041005 = article for April 10th 2005;
 $post_040905 = text for April 9th 2005;
 switch ($_HTTP_GET_VARS['read'])
 {
case post_041005: print($post_041005);
break;
case post_040905: print($post_040905);
break;
default: echo No article was specified.;
 }
 
 Any ideas on why I am receiving only the default message even though 
 I go to the proper article URL?
 
 Best Wishes,
 
 Carlos
   - Original Message - 
   From: Prathaban Mookiah
   To: php-general@lists.php.net
   Sent: Sunday, April 10, 2005 4:23 AM
   Subject: Re: [PHP] Viewing a specific item within a php web-page?
 
   I think you have totally got it wrong. You pass on the value to a 
 php script  in the form on http://   /script.php?variable=value.
 
   So to accomplish your need you may have to do something like call http://
   /script.php?articleid=post_040905.
 
   Your program should be modified to maybe something like:
 
   ?
 
   $post_041005 = article for April 10th 2005;
   $post_040905 = text for April 9th 2005;
 
   switch ($_HTTP_GET_VARS['articleid'])
   {
  case post_041005: print($post_041005);
  break;
  case post_040905: print($post_040905);
  break;
  default: echo No articleid specified
   }
 
   If you still want to call it in the form 
 domain.com/articles.php?post_040905,  then you may do something like 
 this:
 
   $post_041005 = article for April 10th 2005;
   if isset($_HTTP_GET_VARS['post_041005'])
   print($post_041005);
 
   $post_040905 = text for April 9th 2005;
   if isset($_HTTP_GET_VARS['post_040905'])
   print($post_post_040905);
 
   ?
 
   There are more efficient ways to do it, but this should get the 
 job done.
 
   Prathap
 
   -- Original Message ---
   From: Carlos Palomino [EMAIL PROTECTED]
   To: php-general@lists.php.net
   Sent: Sat, 9 Apr 2005 21:23:06 -0400
   Subject: [PHP] Viewing a specific item within a php web-page?
 
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);
   
How can I view a specific string's text via the browser?  I thought
I could use domain.com/articles.php?post_040905  and only the
content written for that post would be shown.  However, all of 
 the   posts are shown. I just began reading about PHP from limited  
  tutorials so I am at a loss as to how I can accomplish this.  I   
 would appreciate all assistance in this matter. Best Regards,  
Carlos
   --- End of Original Message ---
 
   -- 
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
--- End of Original Message ---

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Viewing a specific item within a php web-page?

2005-04-09 Thread Carlos Palomino
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);

How can I view a specific string's text via the browser?  I thought I could use 
domain.com/articles.php?post_040905  and only the content written for that post 
would 
be shown.  However, all of the posts are shown.
I just began reading about PHP from limited tutorials so I am at a loss as to 
how I 
can accomplish this.  I would appreciate all assistance in this matter.


Best Regards,


Carlos