Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Need help displaying my database in PHP!
Old 01-01-2006, 06:05 PM Need help displaying my database in PHP!
Junior Talker

Posts: 1
Trades: 0
Hi everyone, i'm pretty new to mysql, and am wondering how to display the data to a website with PHP. I have looked around trying to find out what I want to do, but no luck.

I made a table called "tricks" with the fields of "id", "type", "name", and "howto".

The id holds the id (of course).
The type holds text of easy, medium, or hard.
The name holds the name of the trick.
The howto holds the information displaying howto do the trick.

Now my question is how do I on one page, display a list of all of the trick names with their type (easy, medium, or hard)? Then, the trick name on that page should be a link, which takes you to a page of it's own displaying the name (this time not a link), type, and howto.

Could anyone please help/explain to me how to get this done?

Thanks in advance
hlstriker is offline
Reply With Quote
View Public Profile Visit hlstriker's homepage!
 
 
Register now for full access!
Old 01-01-2006, 07:31 PM
goldingh99's Avatar
Average Talker

Posts: 20
Trades: 0
you will first have to connect to your server and select your database
then you will need to do a query to get the information from the database

here is some sample code, you will need to change the words in CAPITALS (except SELECT and FROM) to suit your webiste

PHP Code:
<?php
if ($dbc = @mysql_connect ("HOST","USER","PASSWORD")) {
        if (!@
mysql_select_db ("DATABASE")) {
            die (
"<p>Could not select the database because<b>" mysql_error() . "</b></p>");
        }
    }
    else {
        die (
"<p>Could not connect to the database because<b>" mysql_error() . "</b></p>");
    }

$query 'SELECT * FROM TABLE_NAME';
if(
$r mysql_query($query)) {
      while(
$row mysql_fetch_array($r)) {
             print 
$row['type'];
             print 
$row['name'];
             print 
$row['howto'];
      }
}



?>
i hope this helps
goldingh99 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Need help displaying my database in PHP!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10112 seconds with 12 queries