360haven works best with JavaScript enabled
PHP SELECT * FROM
Loading
Register
Login
Results 1 to 2 of 2
  1. #1
    Developer
    Mocha is offline
    Join Date : Dec 2010
    Location : Southampton Pennslyvania
    Posts : 85
    Array

    PHP SELECT * FROM

    So the following will echo out your sql table in xml format. Just a little something I made in my free time.

    PHP Code:
    <?php
    /* MySQL Login Structure*/
    $Host "";
    $DB_Name "";
    $DB_Username "";
    $DB_Password "";

    /*MySQL Table Info/Structure*/
    $DB_Table_Name "";
    $Column_0 "";
    $Column_1 "";
    $Column_2 "";
    $Column_3 "";
    $Column_4 "";
    $Column_5 "";

    /*Performs and selects the database the login to*/
    $Connection mysql_connect($Host$DB_Username$DB_Password) or die("Contact Manager failed to establish a connection to the MySQL database");
    mysql_select_db($DB_Name,$Connection) or die("Contact Manager failed to select the MySQL Database");

    /*Performs the MySQL Query to display the Contact list*/
    $Query mysql_query("SELECT * FROM $DB_Table_Name");
    echo 
    '<?xml version="1.0"?>
    <Root>'
    ;
    while(
    $Rows mysql_fetch_array($Query))
    {
    echo 
    '<Contact>';
    echo 
    '<ID>' $Rows[$Column0] . '</ID>'
    echo 
    '<Username>' $Rows[$Column1] . '</Username>';
    echo 
    '<Gamertag>' $Rows[$Column2] . '</Gamertag>';
    echo 
    '<Name>' $Rows[$Column3] . '</Name>';
    echo 
    '<Aim>' $Rows[$Column4] . '</Aim>';
    echo 
    '<Msn>' $Rows[$Column5] . '</Msn>';
    echo 
    '</Contact>';    
    }
    echo 
    '</Root>';
    mysql_close($Connection);
    ?>
    For displaying the code in a table:
    PHP Code:
    /* MySQL Login Structure*/
    $Host "";
    $DB_Name "";
    $DB_Username "";
    $DB_Password "";

    /*MySQL Table Info/Structure*/
    $DB_Table_Name "";
    $Column_0 "";
    $Column_1 "";
    $Column_2 "";
    $Column_3 "";
    $Column_4 "";
    $Column_5 "";



    /*Performs and selects the database the login to*/
    $Connection mysql_connect($Host$DB_Username$DB_Password) or die("Contact Manager failed to establish a connection to the MySQL database");
    mysql_select_db($DB_Name,$Connection) or die("Contact Manager failed to select the MySQL Database");

    /*Performs the MySQL Query to display the Contacts in a table*/
    $Query mysql_query("SELECT * FROM $DB_Table_Name") or die("Contact Manager could not process the MySQL Query");

    echo 
    "<table border='1'>
    <tr>
    <th>ID</th>
    <th>Username</th>
    <th>Gamer-Tag</th>
    <th>First Name</th>
    <th>Aim</th>
    <th>Msn</th>
    </tr>"
    ;
    while(
    $Rows mysql_fetch_array($Query))
      {
      echo 
    "<tr>";
      echo 
    "<td>" $Rows['Column_0'] . "</td>";
      echo 
    "<td>" $Rows['Column_1'] . "</td>";
      echo 
    "<td>" $Rows['Column_2'] . "</td>";
      echo 
    "<td>" $Rows['Column_3'] . "</td>";
      echo 
    "<td>" $Rows['Column_4'] . "</td>";
      echo 
    "<td>" $Rows['Column_5'] . "</td>";
      echo 
    "</tr>";
      }
    echo 
    "</table>";
    mysql_close($Connection);
    ?> 
    Last edited by Mocha; 03-04-2011 at 12:22 AM.

  2. The Following User Says Thank You to Mocha For This Useful Post:


  3. #2
    Developer
    Mocha is offline
    Join Date : Dec 2010
    Location : Southampton Pennslyvania
    Posts : 85
    Array
    Post updated! I added how to display the MySQL table in a traditional table form.

 

 

Similar Threads

  1. [News] Forza Horizon 2 Playground Select Car Pack
    By THUMBS in forum X1 Game News
    Replies: 0
    Last Post: 08-04-2015, 10:06 PM
  2. Ultra Street Fighter 4 - Edition Select Trailer
    By THUMBS in forum Youtube Famous
    Replies: 3
    Last Post: 03-04-2014, 07:38 PM
  3. [News] Select Inazuma Eleven Anime Episodes Now Available In Nintendo 3DS eShop
    By Serious_M in forum Nintendo News, Updates, and Rumors
    Replies: 1
    Last Post: 02-18-2014, 07:34 PM

Visitors found this page by searching for:

Nobody landed on this page from a search engine, yet!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

About 360haven

    360haven is an Forum Devoted To Game modding Fans from all over the world.

    An Awesome Community of Xbox 360 Gamers, Modders and Developers who Create & Share Tutorials, Applications, Gfx, Trainers and Gamesaves.

    A haven for the l33t.
    A scarce paradise for modders.

Like this page

Google+