Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Posts
    2

    Question Unanswered: Database display on webpage

    Hi, I am very new to Sql and databases etc. I just set up my website as php using MySql for the database. Anyways I would like to show data from the data base on a webpage in a table or something, can someone show me how I can do this?

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Google is your friend.
    also ISBN 1-59059-150-X
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Oct 2004
    Posts
    2
    I don't know what I am searching for, what I want to do is send data through a program I am creating to the database and then display that new info on a webpage just like a games lobby works.

  4. #4
    Join Date
    Sep 2004
    Posts
    13
    Buy a good book on the subject with examples and start practising! I think your question is too vague.

  5. #5
    Join Date
    Oct 2004
    Location
    Manchester, UK.
    Posts
    3

    Trying to Help a Beginner

    Should Help,
    Edit Connection Details, Table, Column, Rows and test it!

    <?php
    // Database Connection Details
    define("DB_SERVER","localhost");
    define("DB_USER","dbusername");
    define("DB_PASS","dbpassword");

    // Open Database Connection
    $db->connect_host(DB_SERVER, DB_USER, DB_PASS);

    // Query the Relevent Table
    $str_SQL = "SELECT * FROM tablename";
    $result = $db->query_db("databasename",$str_SQL);

    // Start to Build the Data Display Table
    $pagetext.='<table align="center" cellspacing="1" cellpadding="3" bgcolor="#000000">
    <tr>
    <td colspan="2" bgcolor="#FFFFFF" align="center">Display Table</td>
    </tr>
    ';

    // If More than "0" Results for the Query
    // Echo Out a Row for Each Result
    if(mysql_num_rows($result)>0)
    {
    $mydata1=$rows['column1'];
    $mydata2=$rows['column2'];
    while($rows = mysql_fetch_array($result))
    {
    $pagetext.=' <tr>
    <td bgcolor="#FFFFFF">'.$mydata1.'</td>
    <td bgcolor="#FFFFFF">'.$mydata2.'</td>
    </tr>
    ';
    }
    }
    else
    // If No Data in the Queried Columns
    // Echo Out a Message within the Table
    {
    $pagetext.=' <tr>
    <td colspan="2" bgcolor="#FFFFFF">No Data to Display</td>
    </tr>
    ';
    }

    // Close the Table
    $pagetext.='</table>
    ';

    // Echo Out the Page
    echo $pagetext;
    ?>

Posting Permissions

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