| View previous topic :: View next topic |
|
| Author |
Message |
Neggi baby piggy


Joined: 08 Mar 2008 Posts: 4 Location: (UK)

|
Posted: Sun Mar 09, 2008 10:45 pm Post subject: PHP Tutorial #1: The Basics |
|
|
I might post one of these every couple weeks if I have the time, just thought I'd help out anyone in need of some PHP advise.
If you have any questions about PHP or JavaScript, please feel free to ask me!
PHP Basic - Tutorial#1.
The easiest thing to do when working with PHP is assign and echo variables.
Here's an example:
| Code: |
<?php
$example = ("Hello, this is an example.");
echo($example);
?> |
Comes out to:
| Code: |
| Hello, this is an example. |
Variables are used a lot in common PHP pages, and can be toyed around with in many ways.
Math is one of the most common ways of manipulating variables.
For example;
| Code: |
<?php
$var1 = 50;
$var2 = 3;
$var3 = 78;
echo("The sum of 50+78x3 equals ".($var1+$var3*$Var2).".");
?> |
Comes out as;
| Code: |
| The sum of 50+78x3 equals 284. |
You can grab variables from the page URL too!
Have you ever noticed that in some websites, for example; Google, links can refer to URLs like "http://www.google.com/search?hl=en&q=example"?
That's because the index page of Google uses PHP to search for the variable defined by the "&q" string.
Here's an example for a webpage with the URL "http://www.nogginanimations.com/?p=home";
| Code: |
<?php
$page = $_REQUEST['p'];
if ($page=="home") {
echo("This is the home page.");
} else {
echo("This is not the home page.");
}
?> |
That's about all I can bother with for today, but stay tuned for more! |
|
| Back to top |
|
 |
clutz1988 piggy


Joined: 04 Jan 2008 Posts: 69 Location: good ol' UK
       

|
Posted: Mon Mar 24, 2008 10:04 pm Post subject: |
|
|
I...Love...You
I've been trying to get a logout button to work on my website for ages as i couldnt get it to put &SID into the URL.
again...I LOVE YOU  _________________ This sig sucks, i threw it together in 10 mins on photoshop.
"Tea tastes like ass juice, I know this because I've tasted tea." |
|
| Back to top |
|
 |
Neggi baby piggy


Joined: 08 Mar 2008 Posts: 4 Location: (UK)

|
Posted: Sun Mar 30, 2008 7:34 am Post subject: |
|
|
heheh, you're very welcome!
Glad I could help someone out! |
|
| Back to top |
|
 |
pig2cat The king


Joined: 01 Jan 1970 Posts: 4279
                            

|
Posted: Tue Jul 15, 2008 6:40 pm Post subject: |
|
|
| j0rdan01 wrote: |
I knew that, and I hate and will NOT learn PHP for the obvious reasons or it's poor, a failed attempt at a language, used my millions and overrated and easy.
Anyway, lessons learnt for at least 1 person, congratulations. |
Hmm I Prefer php over other languages since it's simple and really easy to use html with :O (and its the only language I know quite well ^^) _________________
Piggymoo redesign:
Scripting forum: 1st section done, second put on hold
GFX: 1st section 50%, second put on hold
scripting frontpage: 70% done
make update cms: 30% done |
|
| Back to top |
|
 |
ezxen God


Joined: 09 Mar 2007 Posts: 2429 Location: Ascended plain
   

|
Posted: Thu Jul 17, 2008 4:27 am Post subject: |
|
|
I got a question . say i was building a forum form scratch and wanted to get a quote system going . COuld someone show me how that would look .
Like When the quote button is clicked it copy's the text from the post _________________ Ask not what Piggymoo can do for you but what you can do for Piggymoo
I am the Alpha and the Omega
 |
|
| Back to top |
|
 |
pig2cat The king


Joined: 01 Jan 1970 Posts: 4279
                            

|
Posted: Thu Jul 17, 2008 10:23 am Post subject: |
|
|
| ezxen wrote: |
I got a question . say i was building a forum form scratch and wanted to get a quote system going . COuld someone show me how that would look .
Like When the quote button is clicked it copy's the text from the post |
if you want it to be copied onto a reply page(like here on this forum), it's really easy
to just make a link to quote, with the post ID in it(posting.php?mode=quote&p=68138)
get in your posting file the parameters from the url(with $_HTTP_VARS or $_GET)
run an sql query which gets the data from the text section of the post($sql = "select `text`, `poster` from `database` WHERE `ID` = '$pnumber' limit 1";
$result = mysql_query($sql);
$lala = mysql_fetch_array($result);
$text = $lala['text'];
$poster = $lala['poster'];
)
pretty much that actually
then just return it in the textform
<forn>
<textarea name=bla>
[quote= <? print $poster; ?>]
<? print $text; ?>
[/ quote]
</textarea> _________________
Piggymoo redesign:
Scripting forum: 1st section done, second put on hold
GFX: 1st section 50%, second put on hold
scripting frontpage: 70% done
make update cms: 30% done |
|
| Back to top |
|
 |
|