PC Pals Forum
Technical Help & Discussion => Website Design & Programming => Topic started by: Corky on November 04, 2002, 08:15
-
St Adept ;D would it be possible to have a Coding tutorial section here? PLEAAAAAASE. It may come in handy.. What do u think?
-
I'd be happy with that as I need to learn all about it. I'm slowly learning SQL, erm I think :- and trying to understand html and php. Now trying to do all those at the same time is not helping my brain ::)
-
I would be happy to learn all of those bat. as I need to make my own website a lot better, It is very basic at the moment.
-
sql is the easier of the lot. When using php the most common commands are
SELECT
DELETE
UPDATE
I would be more than happy to help you out when ever you need it.
Corky
-
Right lets start at the beginning ;)
I got a tutorial CD for SQL, which I'm slowly going through.
As for doing up your web site, I use Dreamweaver, although FirstPage 2000 is great for beginners and comes with loads of add-ins which look good. Its also free ;D I'll post the url later when I've found it, if you want FP2000
-
I have dreamweaver mx ;D.
Yes start right at the beginning.
Are you only doing Sql? or the others aswell.
Where you get the disk from Bat?
-
ok, the begining....
PHP:
php files must start with <?PHP or <? lines are terminated by ; unless a { is there
to connect to MYSQL through PHP, use this code:
$connect = mysql_connect("localhost", "databaseusername", "databasepassword");//connects to the database
$select = mysql_select_db("databasename"); //selects the database
$connect is now a short name for mysql_connect("localhost", "databaseusername", "databasepassword");
and $select is a short name for mysql_select_db("databasename"); . They may not need to be used that often, but some query's may need to use them from time to time.
Next, query's:
After typing the connect code add this code below mysql_select_db... :
$query = mysql_query("SELECT * FROM databasetable"); //selects where the data is coming from in the table.
Now, if you want to display data from the database on a page you use:
while ($row = mysql_fetch_array($query)) {
$get1 = $row["get1"];
$get2 = $row["get2"];
$get3 = $row["get3"];
//and so on.
now to display the data it has to be echo'd through php. So add:
echo"$get1";
echo"$get2"; //html can be added here, but errors will emerge if there are " (quotes) in the code, you can avoid the errors by adding a in from of the " so for example <td height="20"> looks like this <td heigh="20">
echo"$get3";
//and so on.
now that this data has been set to echo you can close this by adding a } at the end.
now close the code with ?>
Fullcode:
<?PHP
$connect = mysql_connect("localhost", "databaseusername", "databasepassword");
$select = mysql_select_db("databasename");
$query = mysql_query("SELECT * FROM databasetable");
while ($row = mysql_fetch_array($query)) {
$get1 = $row["get1"];
$get2 = $row["get2"];
$get3 = $row["get3"];
echo"$get1";
echo"$get2";
echo"$get3";
}
?>
Right, who's still awake? ok rephrase... Who is still awake and understood a word of that?
Let me know what u are having trouble with and ill explain it more indepth.
Corky
-
Corky I said at the begiinning ;D.
What does each one do and what they can be used for?
A very simple tutorial on using it?
-
perhaps these ppl could teach you better.
http://www.webmasterbase.com/
-
I didn't start using php with tutorials or help. I jumped straight in at the deep end and edidted code of other peoples work. I didn't copy it, i used it as a guide to build my own.
I think i will have to work on my tutorial building :)
-
perhaps these ppl could teach you better.
http://www.webmasterbase.com/
Are ytou just trying to say "OMG he knows nothing" lol.
I am hopefully going on a dreamweaver course. Still have to sort it out though.
-
no not at all Jimmy :) I re-read what i had written, and it looked pretty confusing for me!
The people at webmasterbase have been coding for donkies years so it may be better.. So just ask me if something goes wrong ;D
Corky
-
Where you get the disk from Bat?
A friend at work gave me it :o
Seems quite good, but I think it will have to take a back seat now as I'm having truble with this PC and I'm loath to reformat it as I want to use it until my new machine is finished, hopefully soon.
Ohh dear Corky, seems I'm not learning fast enough, I was reading Greek there ;) I think ::)
-
hehe, it was all Greek to me when i first started too but you get used to it after a while. :)
-
Well I always hated languages at school, apart from programming that is, that was fun, especially when the teacher hadn't a clue what I was writing, it was well beyond her, hee hee
-
hehe, i know what you mean :) It was quite amusing to prove teachers wrong or go one better than them, espscially when they give you s**te loads of assignments :)