Closed Thread
Page 4 of 4 FirstFirst ... 234
Results 31 to 38 of 38

Thread: Displaying records from a mySQL DB

  1. #31
    Arctic Fire is offline Learning Programmer
    Join Date
    Aug 2009
    Posts
    48
    Rep Power
    0

    Re: Displaying records from a mySQL DB

    Something like this should work. You can add more data to each row if you want.

    Code:
    <?php

    mysql_connect
    ("localhost","username","password");
    mysql_select_db("database_name");

    $id = (int)$_GET['id'];
    $query mysql_query("SELECT * FROM teams");

    if(
    mysql_num_rows($query) == 0)
    {
        echo 
    "No Teams";
    } else {
        echo 
    "<table>";
        while(
    $row mysql_fetch_assoc($query))
        {
            echo 
    "<tr><td><a href=\"teaminfo.php?id=".$row['id']."\">".$row['TeamName']."</a></td></tr>";
        }
        echo 
    "</table>";
    }

    ?>

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #32
    dp26 is offline Newbie
    Join Date
    Mar 2010
    Posts
    13
    Rep Power
    0

    Re: Displaying records from a mySQL DB

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/northsta/public_html/tmp/teamsnew.php on line 9
    No Teams

  4. #33
    Arctic Fire is offline Learning Programmer
    Join Date
    Aug 2009
    Posts
    48
    Rep Power
    0

    Re: Displaying records from a mySQL DB

    Replace

    $query = mysql_query("SELECT * FROM teams");

    with

    $query = mysql_query("SELECT * FROM teams") or die(mysql_error());

    Paste back here what it says.

  5. #34
    dp26 is offline Newbie
    Join Date
    Mar 2010
    Posts
    13
    Rep Power
    0

    Re: Displaying records from a mySQL DB

    No database selected

  6. #35
    Arctic Fire is offline Learning Programmer
    Join Date
    Aug 2009
    Posts
    48
    Rep Power
    0

    Re: Displaying records from a mySQL DB

    You did fill in your database name in the "mysql_select_db("database_name");", right?

  7. #36
    dp26 is offline Newbie
    Join Date
    Mar 2010
    Posts
    13
    Rep Power
    0

    Re: Displaying records from a mySQL DB

    working now, i had the wrong database

  8. #37
    Arctic Fire is offline Learning Programmer
    Join Date
    Aug 2009
    Posts
    48
    Rep Power
    0

    Re: Displaying records from a mySQL DB

    That'll do it everytime.

    Need help with anything else?

  9. #38
    dp26 is offline Newbie
    Join Date
    Mar 2010
    Posts
    13
    Rep Power
    0

    Re: Displaying records from a mySQL DB

    Check your personal messages, last question, i think!

Closed Thread
Page 4 of 4 FirstFirst ... 234

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. mysql records
    By tontonskie in forum Database & Database Programming
    Replies: 4
    Last Post: 12-13-2010, 04:18 PM
  2. Displaying MySQL data in HTML with PHP
    By dunnkers in forum PHP Development
    Replies: 4
    Last Post: 07-16-2010, 08:53 AM
  3. How can I delete mySQL records from an html or jsp page?
    By bigz008 in forum Database & Database Programming
    Replies: 2
    Last Post: 03-05-2010, 09:37 AM
  4. displaying mysql data into jtextfield.Pls help
    By iz.ziffa in forum Java Help
    Replies: 1
    Last Post: 05-31-2007, 08:58 AM

Tags for this Thread

Bookmarks

Posting Permissions

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