[Immortal GamerZ]Php Guide! Part 1(Variables+more!) menu

Shout-Out

User Tag List

Results 1 to 2 of 2
  1. #1
    bsod-staff14's Avatar Member
    Reputation
    35
    Join Date
    Nov 2008
    Posts
    443
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Immortal GamerZ]Php Guide! Part 1(Variables+more!)

    Hello, I'm Matt from Immortal GamerZ! Here to give you a simple short guide on a few simple php items .

    First of all lets start out with Variables. Lets explain what they are. Variables are basically a short term like $title to be very very easy to use more then once instead of typing it over again here are some examples:

    Code:
    <?php
    $title='Immortal GamerZ';
    $dbhost='DB Host';
    $dbuser='DB User';
    $dbpass='DB Pass';
    $dbname='DB Name';
    $user_table='User Table';
    $link_table='Links Table';
    $staff_table='Staff Table';
    ?>
    Now here's the code to use these in a page
    Code:
    <?php
    include("config.php");
    ?>
    <html>
    <head>
    <title><?php echo $title; ?>
    </title>
    </head>
    <body>
    Hello Everyone!
    </body>
    </html>
    Lets break this all down for you. You see <?php ?> is the normal php tags that you use in all php page's. Echo is what you use when you want to display text of some sort. $title; is what you use when you are displaying a variable or variable text.
    Lets move onto MySQL Connection .

    Code:
    <?php
    $username="DB User";
    $password="DB Pass";
    $database="DB Name";
    mysql_connect(DB Host,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    ?>
    That is about as basic connecting to MySQL Through php can get!
    Now lets move onto displaying data from a table:

    Code:
    <html>
    <head>
    <title>News System-Immortal GamerZ</title>
    </head>
    <body>
    <?php
    $username="DB User";
    $password="DB Pass";
    $database="DB Name";
    
    mysql_connect(DB Host,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM articles";
    $result=mysql_query($query);
    
    $num=mysql_numrows($result);
    
    mysql_close();
    ?>
    <?php
    $i=0;
    while ($i < $num) {
    
    $title=mysql_result($result,$i,"title");
    $author=mysql_result($result,$i,"Author");
    $body=mysql_result($result,$i,"body");
    ?>
    <center><div style="width:420px; margin-bottom:30px;">
    <?php echo $title; ?><br><hr>
    <?php echo $body; ?><br><hr>
    By:<?php echo $author; ?></div><br>
    <?php
    $i++;
    }
    ?></center>
    </body>
    </html>
    Okay that's all I have for ya today! I hope you enjoy it!
    Immortal GamerZ Under Development!

    [Immortal GamerZ]Php Guide! Part 1(Variables+more!)
  2. #2
    AndreasG7's Avatar Member
    Reputation
    10
    Join Date
    Dec 2007
    Posts
    143
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks so so so much this is exactly what I needed
    +REPx2
    Last edited by AndreasG7; 08-15-2009 at 09:30 AM.

Similar Threads

  1. [Immortal GamerZ]HTML Tutorial! Part 2(Advanced)
    By bsod-staff14 in forum Programming
    Replies: 4
    Last Post: 07-18-2009, 09:34 PM
  2. [Immortal GamerZ]HTML Tutorial! Part 1
    By bsod-staff14 in forum Programming
    Replies: 4
    Last Post: 07-17-2009, 05:55 PM
  3. [Guide] How to make more then 1 realm
    By Djfrederick in forum WoW EMU Guides & Tutorials
    Replies: 25
    Last Post: 02-23-2009, 08:28 AM
  4. [TuT/Guide] PHP Guide/Tutorial
    By Krilio in forum Programming
    Replies: 9
    Last Post: 04-11-2008, 10:00 AM
  5. ZG Guides (Part 2)
    By Cush in forum World of Warcraft Guides
    Replies: 0
    Last Post: 05-28-2006, 03:01 PM
All times are GMT -5. The time now is 11:00 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search