[PHP] New PHP User with a simple question

2009-01-24 Thread Christopher W
At least I hope it is simple...

I am trying to get an HTML menu link to set a variable's value.  For 
example, when a user clicks the "Home" button on my page it would cause 
$page = "home"; or clicking the "About Us" button will set $page="about_us"; 
etc.

I think this should be fairly simple but being completely new to php I just 
cannot seem to get it right.

Any help would be greatly appreciate.

Thank you in advance.
-- 




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



Re: [PHP] New PHP User with a simple question

2009-01-24 Thread Christopher W
Sorry, I am also new to the etiquette of these mail lists.

Anyway what I was attempting to do, in the full picture, was be able to just 
switch the text in the text area without actually changing pages.  For 
example, if the user clicks "About Us" (from the home page) the page doesn't 
change, just the text (in the area I designated for text).

Since I have never used php before (but have read some online and in books) 
what I was trying was:

if ($page == "home") {echo $home_text;}
elseif ($page == "about") {echo $about_text;}
...
else {echo $error_text;}

My problem is that I can't figure out how to get the link-click to assign 
the value to the variable.  I didn't try any php for that end because I 
really didn't know where to begin.

Thanks for the replies and the help.  I truly appreciate it.

-- 

"Lars Torben Wilson"  wrote in message 
news:36d4833b0901242313r435860b3q7f3f4f0eea621...@mail.gmail.com...
> 2009/1/24 Christopher W :
>> At least I hope it is simple...
>>
>> I am trying to get an HTML menu link to set a variable's value.  For
>> example, when a user clicks the "Home" button on my page it would cause
>> $page = "home"; or clicking the "About Us" button will set 
>> $page="about_us";
>> etc.
>>
>> I think this should be fairly simple but being completely new to php I 
>> just
>> cannot seem to get it right.
>>
>> Any help would be greatly appreciate.
>>
>> Thank you in advance.
>
> Hi there,
>
> A good way to increase your chance of getting a useful response is to
> post the smallest example you can which clearly illustrates the
> problem you're having. In this case, you say you're not able to get
> this to work, but we could waste quite a bit of time trying to guess
> what you've tried and what didn't work.
>
> In the simplest case, you could make your menu items look something
> like this: Home and then use $page
> = $_GET['page'] in your script, but I wouldn't recommend it since now
> you have user data floating around in your script and it will later
> become a pain in the butt to sanitize for security. For a learning
> script it'll be fine though.
>
>
> Torben 



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



Re: [PHP] New PHP User with a simple question

2009-01-24 Thread Christopher W
mation by doing
> print_r($_SERVER), and seeing what bits and pieces you can put together,
> but that's not nearly as good or reliable.
>
> Sorry if there's too much info, but I'm guessing this is roughly what
> you'll be doing.
> If you want to have more than one variable (like say a sub page) then
> you add  *&* between each variable. E.g
>
>Home -
>Archived News
>
> You can usually get away with just using *&* as the separator but it
> probably won't validate properly if your making it in xhtml (as you
> should be). Also, if your not sure what the %20 means (a space) then
> look up urlencode <http://au.php.net/manual/en/function.urlencode.php>
> and urldecode <http://au.php.net/url_decode>.
>
> Michael Kubler
> *G*rey *P*hoenix *P*roductions <http://www.greyphoenix.biz>
>
>
>
> Christopher W wrote:
>> At least I hope it is simple...
>>
>> I am trying to get an HTML menu link to set a variable's value.  For
>> example, when a user clicks the "Home" button on my page it would cause
>> $page = "home"; or clicking the "About Us" button will set 
>> $page="about_us";
>> etc.
>>
>> I think this should be fairly simple but being completely new to php I 
>> just
>> cannot seem to get it right.
>>
>> Any help would be greatly appreciate.
>>
>> Thank you in advance.
>>
> 



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



Re: [PHP] New PHP User with a simple question

2009-01-26 Thread Christopher W
Kevin,

Your link, with some modifications to fit my site layout, worked just as I 
was hoping for.

Thank you very much.

-- 

"Kevin Waterson"  wrote in message 
news:20090126092451.7aab63ff.ke...@phpro.org...
>
>> > Sorry, I am also new to the etiquette of these mail lists.
>
> Hope this will get you started,
>
> http://www.phpro.org/tutorials/Introduction-to-PHP-templating.html
>
> Kevin
>
> http://phpro.org
> 



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



[PHP] Re: New PHP User with a simple question

2009-01-26 Thread Christopher W
Dear responders,

I was not sure which post was the best to respond to all of you so I chose 
the original.

I wanted to thank you all for taking the time to try and help answer my 
question.  I truly appreciate it.

For the record, I have a PHP book and I understand (I think) all the 
variables, functions, conditionals, loops, constants, etc. of PHP.  My 
problem, with no computer programming to speak of, was putting those 
variables, functions, conditionals, loops, constants, etc. together to make 
it do things I was hoping to accomplish.  I am hoping that with reading more 
tutorials, looking at other people's php files and lots of practicing I may 
one day "get it."

I am truly grateful for all the time all of you spent in trying to help.

-- 

""Christopher W""  wrote in message 
news:f5.56.55096.935eb...@pb1.pair.com...
> At least I hope it is simple...
>
> I am trying to get an HTML menu link to set a variable's value.  For 
> example, when a user clicks the "Home" button on my page it would cause 
> $page = "home"; or clicking the "About Us" button will set 
> $page="about_us"; etc.
>
> I think this should be fairly simple but being completely new to php I 
> just cannot seem to get it right.
>
> Any help would be greatly appreciate.
>
> Thank you in advance.
> -- 
>
>
> 



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