...

View Full Version : Looking for somebody who will tutor me in PHP



jenmarie
02-19-2006, 04:52 PM
I want to learn PHP, but reading tutorials is getting hard for me. I learned HTML by looking at the coding and the webpage and matching up the codes to what it does. It's hard to find php scripts for websites because when you look at the source it's all in HTML. I'm a quick learner so you won't have to help me for very long. I just need somebody to guide me through it.

I want to be able to create a website similiar to this

http://www.rachelmcadams.org

I could probably figure out how to do that layout in HTML, but she uses PHP and I was wondering if one of you all could figure out what she did and explain it to me.

I hope I explained myself well enough...

StupidRalph
02-19-2006, 05:05 PM
I think you may have to bite the bullet on this one. And try to take a few tutorials and there are some that are pretty straight forward. Atleast take a tutorial and build up some kind of foundation. This would make it easier for you and your tutor. PHP tutorial (http://www.w3schools.com/php/default.asp) If you have any questions then I am sure the folks here wouldn't mind helping you. But try and help yourself a little first.

jenmarie
02-19-2006, 05:11 PM
I actually have already. I've been reading up on tutorials on various different sites, all of which say the same thing. I've looked at a few scripts I downloaded from various places and can point out variables, functions, etc. I have a bit of basics already. It's the application part that's getting to me. I already asked my former host to set up an account for me that I can practice with. I just can't figure out how to use php. I could make a website using frames, a css file, and tables and make it like that Rachel site, but I want to try using PHP instead.

vinyl-junkie
02-19-2006, 05:50 PM
If you don't find that you are able to learn well using online tutorials, perhaps getting a book would help you better. I would hightly recommend Build Your Own Database Driven Website Using PHP & MySQL (http://www.sitepoint.com/books/phpmysql1/). This book is great for beginners and starts out simple, building on each concept as it goes. There are quite a few scripts in the book, each of which is accompanied by an explanation of how they work. Best of all, you can download the first few chapters of the book to try it before you buy it.

goughy000
02-19-2006, 08:01 PM
At the bottom of the page you linked to it says


Powered by cutenews

You can download a version of cutenews for free and dont need much php knowledge to install it, it dosnt even use a database

google it

jenmarie
02-19-2006, 10:39 PM
Oh thanks. I didn't notice that.

So how would I use PHP to make a "template" sort of thing? Hm, this might be a little long-winded, excuse me.

You know how you can use a css file and frames to make a website so whenever you change the layout, you only have to change the css file and positioning the frames? That's how I used to make websites. How would I convert a website like that over to PHP? I can't figure out how people use PHP in their websites.

Like, for example, another Rachel website (I was on a 'The Notebook' picture spree last night)

http://www.rachel-mcadams.com/

If I were to code it, I would've used frames. To make a website that huge, I couldn't possibly come up with the time to change every single page each time I changed the layout, so I would use frames so I would only have to change one page. Is there a way to use PHP instead?

I don't understand how I would to do that and that's what I wanted somebody to help me with. I want to save myself time and also stop using frames because they start be annoying after a while.

I apologize if I'm confusing, but I'm sort of confused myself. Help?

degsy
02-21-2006, 02:30 PM
http://www.zend.com/php/beginners/index.php

You have a couple of options for a template.

You can create a few files which you will include on every page

e.g.
header.php
menu.php
footer.php


page.php


<?php
include('header.php');
include('menu.php');
?>
<!-- CONTENT -->
<h1>hello</h1>
<?php
include('footer.php');
?>



Another option is to have a full template page where you include the content. This can also be referred to as a content management system.



<?php
include('header.php');
include('menu.php');
?>
<!-- CONTENT -->
<?php
include($_GET['page']);
<?php
include('footer.php');
?>

This is a basic example
http://degs.co.uk/test/hct/include%20via%20url/

neil.johnson
02-21-2006, 05:23 PM
Hi

I think you are getting a little confused! There is no conversion from HTML, CSS to PHP. PHP code is more than often embedded inside HTML. The fact that the page has a .php extension suggests this (although using PERL's MOD_REWRITE allows you to basically use any extension but dont worry about that right now). PHP is used to add dynamic functionality to a web site as the http protocol is purely static and HTML on its own cannot achieve this.

Let me give you a quick example

Here is a bit of HTML that prints out usernames and login times (this may be used as some kind of report)
<table>
<tr>
<th>Username</th>
<th>Last Login</th>
</tr>
<tr>
<td class="user">Joe.Bloggs</td>
<td class="login">01/01/2006</td>
<tr>
<tr>
<td class="user">Super.Man</td>
<td class="login">15/01/2006</td>
<tr>
</table>

Now this is a bit pointless really because using HTML on its own means that you have to manually add to the table to keep the report upto date for you system admin to see. What we need is a database that stores usernames and login times that we can report on. HTML does not have the ability to connect to any database so that is where PHP comes into play.

Here is the above example again only this time we are using a loop in PHP to list out all the users and their logon times from a database (Forget about the code syntax if you are learning).

<table>
<tr>
<th>Username</th>
<th>Last Login</th>
</tr>
<?php
$db->query("select name, logintime from users");
while($row = $db->fetchRow()) {
?>
<tr>
<td class="user"><?php print $row['name']; ?></td>
<td class="login"><?php print $row['logintime']; ?></td>
<tr>
<?php } ?>
</table>

Like the other posts mention, you require a beginners guide to kick start yourself. The penny will drop. If you want to make a web site like the one you mention then use your HTML,CSS knowledge to build up a page template but save the files with a .php extension. Then when you get to grips with php you can start to embed your php code in the template to print out news items, pictures, etc..

Obviously your testing server requires php be installed or files with a .php extension will not run. You cannot preview .php files in your web browser from a local file location either unless php is running on your own computer.

jenmarie
02-22-2006, 10:24 PM
Thanks for that website. I haven't ever come across it before and at a glance it looks really helpful (It'll give me something to look at during the ridiculous american idol commercials. What happened to the one-sponsor thing?!)

I guess I worded it wrong. I didn't really mean "convert". I guess I just wanted to figure out how to use PHP instead of gobs of HTML that gets crazy when a website gets so big.

I'm trying to get a paper started at my school and my principal mentioned wanting it online since it's easier. I knew that would bring a huge obstacle because we'd have to find somebody to make it and I thought if I could master PHP over the summer and make the website myself and keep it up it'd be so much easier. I found this one online paper that looked REALLY awesome and I realized that it was all coded in PHP. I hope I can get a hang of it!

Pennimus
02-22-2006, 10:43 PM
Perhaps it would be useful if I mentioned how I learnt PHP.

To begin with I built a page for a site as normal using HTML and CSS. I then identified areas of that page that would be identical or near identical on every single page. As suggested above, these areas will typically be the header, navigation and footer of each page.

Then, I started taking the code for these sections out of the main template and putting it in a seperate file. These seperate files are then called in to the main template by use of <?php include('file');?>. Once you've done that, you can happily build a 1000 page site knowing that you'll be able to change the included sections of every page simply by editing one file.

Later, I began to realise that while this was pretty great, without embellishment it's also fairly inflexible. What if I wanted to have slightly different navigation on a few pages, or add a banner to the homepage only? This is where you start picking up on some of the other slightly more advanced basics of php - things like switch statements and if/else statements that allow you to generate a different outcome based on criteria that you set. In the above examples, you could use php to fetch the current URL of the page, and then change the content of the header or navigation areas based on this.

Learning while doing a task like this is the best way to pick things up if you ask me. The above gives you the basics of a quickly editable website; when combined with clever use of CSS you can achieve your goal of being able to change the layout, design and content of an entire site very quickly.

Until you have done the above, I wouldn't worry about trying to learn anything more than the basics. It's one of those things where you can just keep building up the complexity of the code as you go quite happily.

I did however have a book on php to hand at all times and this proved invaluable, I would definately advise you to buy one -- it doesn't have to be a huge tome, any small beginners guide is going to do the job. Also, the PHP manual (http://uk.php.net/) is great for finding out what a particular function does and how to implement it. Meanwhile, this forum is great for finding out what function you need to achieve a particular outcome in the first place :thumbsup:

Hope that's of some use...

SpirtOfGrandeur
02-22-2006, 10:47 PM
My consulting fee is 175$'s an hour. If you can afford it I can do what ever you want me to do ;)

jenmarie
02-22-2006, 10:50 PM
You must be rich, Spirt! :p

I was trying to read up on switch statements when I figured out that's what the rachel site was using (or I think it was that site. Might be the school paper site). It changes the URL does it not? Because I was looking at the switch tutorial and it was like php?x=whatever and the whatever was a case. I didn't quite understand the point of using them. Somebody mind letting me in on the great use of it? Or correct me if what I think it is is wrong.

SpirtOfGrandeur
02-22-2006, 10:54 PM
You must be rich, Spirt! :p

You dont have to pay health care...

Pennimus
02-22-2006, 11:51 PM
I was trying to read up on switch statements... It changes the URL does it not?

That's not quite correct, it's more likely what you were reading was changing something else based on the URL.

Switch is used to compare one value to a number of other values (the individual cases you were talking about) and when php finds a match it executes the code found in the matching case. An incredibly simple (and completely useless) example using a switch statement - I have commented this throughout so you can see what's going on.


<?php
$number = 2 //this sets the value of $variable to 2.

switch ($number) { //this tells php that it should compare $number to the different cases within the switch statement.

case 1: //the first case
$text = 'Case 1 is a match'; //the resulting code should case 1 be a match for $number, in this case I simply assigned some random text to the $text variable.
break; // a break ends each case.

case 2:
$text = 'Case 2 is a match';
break;

case 3:
$text = 'Case 3 is a match';
break;

default:
$text = 'None of the cases matches the value of $number';
break;

} // remember to close the switch statement!

echo $text; // prints out the text assigned to the $text variable.
?>


So what is the end result of this code?


Case 2 is a match

Can you see how this works in essence now?

jenmarie
02-23-2006, 12:25 AM
I guess. But what's the point? How do you use that with the websites?

http://www.digital-web.com/articles/easypeasy_php/

That's the tutorial I was reading about switches. I saw that it had $id in it and then in the website links it was ?id so that's how I connected it. They also used include.

This all just gives me a headache, haha. Maybe I should tackle it when I really know what my website to look like. Gee, Jen, what an idea. :rolleyes:

Thanks for helping though. I appreciate it.

Pennimus
02-23-2006, 12:36 AM
Meh... not much use, that was a very basic example to illustrate how they work. As I said before, the use I originally found for switch statements was to change the content in my includes slightly based on the URL.



switch (basename($_SERVER['PHP SELF'])) {

case index.php:
//do whatever needs to be done on this page
break;

case contactus.php:
//do whatever
break;

}



And so on ... A great use for this is to change the appearance of links when you are on the page the link refers to. Another might be to have some links displaying on certain pages and not on others. The possibilities are endless once you have grasped the basics.

Anyway, enough tutoring - I suggest you go away and try and produce something, it will be a lot more productive with your time.

fci
02-23-2006, 12:52 AM
in this context, think of a switch statement like switchboard. you switch between different content depending on a URL.
call this index.php:


<html>
<title>My site is ROFL GrrReat!</title>
<body>
<table>
<tr><td width="100">Hey!</td>
<td>
<?php
switch ($_GET['action']) {
case 'contact' :
print 'You can email me at joe@joe.com';
break;
default:
print 'Thanks for viewing my site! <a href="index.php?action=contact">click here to contact me</a>';
break;
}
?>
</td></tr></table>
</body>
</html>
it is a fairly simple example



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum