[SOLVED] design questions and specifics

03-06-08, 02:13 PM
|
|
Newbie Coder
|
|
Join Date: Mar 2008
Location: Canada, midwest
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
[SOLVED] design questions and specifics
general q:
i am new to php and need some coding philosophy to follow. Is it better to have lots of little scripts that call each other, or one big script that uses a bunch of include files for smaller functions or is there something better yet? I am missing the general sense of how general coding should go.
specific q:
what does the "?" do in this segment:
echo"$_SERVER[PHP_SELF]?action=some_fn...
|

03-06-08, 03:28 PM
|
 |
Code Master
|
|
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
It's best to make groups of useful functions that you will use again in one file, and include the file as needed. as for the ? in that code, it is there simply to make a link with the GET method
|

03-06-08, 03:51 PM
|
|
Newbie Coder
|
|
Join Date: Mar 2008
Location: Canada, midwest
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for that. Are hyperlinks more popular as navigation tools than using the html submit button? When should each be used?
|

03-06-08, 03:54 PM
|
 |
Code Master
|
|
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Submit buttons for submitting data in forms, and hyperlinks for linking to other pages 
|

03-06-08, 04:00 PM
|
|
Newbie Coder
|
|
Join Date: Mar 2008
Location: Canada, midwest
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok. let's see if I got it. use buttons when there is information to be sent, and use links when no info required?
|

03-06-08, 04:05 PM
|
 |
Code Master
|
|
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes basically. If you want a user to submit information, you use submit buttons generally. the only real reason you would need to use hyperlinks with the ? is if you have a page with different options depending on a paramater, for example if your hyperlinks had the following values
page.php?p=1
page.php?p=2
page.php?p=3
depending on which of the three were clicked, your page called 'page.php' could determine which page to show, i.e. page 1, 2 or 3
Hope that clears it up
Jay
|

03-06-08, 04:16 PM
|
|
Newbie Coder
|
|
Join Date: Mar 2008
Location: Canada, midwest
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok, that makes sense.
thanks Jay.
1.) What is the best way to send great gobs of seemingly unrelated data to the next "page"? Arrays?
2.) javascript like: history.go(-1), which returns to the previous page, is this server-side? Is this only going to work if the client has java? or this part of php even though it's really java?
Fred
|

03-06-08, 04:23 PM
|
 |
Code Master
|
|
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
1) If you dont want the data seen whatsoever by the user, you can store them in session variables. They are all server side, so none of it gets transferred to the client browser, but is remembered by the server for the whole of the users visit (as long as the session doesn't expire)
2) history.go(-1) is not server side, as it runs on the clients browser. therefore, client side. it has absolutely nothing to do with either the server or php, and will work without them
Jay
|

03-06-08, 04:33 PM
|
|
Newbie Coder
|
|
Join Date: Mar 2008
Location: Canada, midwest
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i appreciate your quick responses.
so, mouse over, blur and other similar javascripts must also be client side too? and actually depend on the user's browser's make, version and wheather they have java enabled?
what is recommended, use embedded javascript in php, or use a php solution?
|

03-06-08, 04:49 PM
|
 |
Code Master
|
|
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes, all javascript is client side. it is not on the server whatsoever. PHP is server side, therefore it is processed before it ever reaches the client. for example, if you have the php code
the server will take that script, parse it and insert the result where the <?php and ?> are between. if you look at the source code for your page it will only show Example text. No other part of the script is displayed or sent to the browser
for a more indepth explaination of what exactly happens serverside or client side, I suggest you look at the manuals for the different scripting languages
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|