SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Oregon
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to list somthing...?

    PHP Code:
    <?
    $dot 
    mysql_query("SELECT * FROM table ORDER BY dot DESC LIMIT 5");
    if (
    $row mysql_fetch_array($dot)) {
    do {
    $dot_name $row["dot"];
    print (
    "<tr><td width=100%> $dot_name</td></tr>");
    } while (
    $row mysql_fetch_array($dot));
    }
    ?>
    So how would I make it so it shows 1.,2.,3.,4.,5. like a list? I tired using the
    HTML Code:
    <ol> and <li>
    tags but it showed up as
    HTML Code:
    <ul> and <li>
    . Is there any other way to list somthing?

  2. #2
    SitePoint Guru augathra's Avatar
    Join Date
    Jul 2004
    Location
    united states
    Posts
    826
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im not sure what your vars are but here's a method:

    PHP Code:
    $xp mysql_query("SELECT * FROM table ORDER BY dot DESC LIMIT 5"); 
    echo 
    '<ol>';
    if (
    $row mysql_fetch_array($xp)) { 
    do { 
    echo 
    '<li>' $row['dot'] . '</li>';
    } while (
    $row mysql_fetch_array($xp)); 

    echo 
    '</ol>'
    That is numbered. If you want bullets, change the <ol> to <ul>, don't forget the closing tag either.

  3. #3
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Oregon
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well just to let you guys know, the bullets do apear, my way and augathra's way, but I need a way to show the numbers... Maybe my browsers screwed up or something but the numbers just don't show up when I use the <ol> tag it converts to bullets...

  4. #4
    SitePoint Addict loadx's Avatar
    Join Date
    Jul 2004
    Location
    Melbourne, VIC, Australia
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe this will help
    http://www.htmlhelp.com/reference/wilbur/list/ol.html

    thought if your using the above code all should work well :S
    weird

    good luck

  5. #5
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Oregon
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I already know that stuff... Im only having problems inserting an orderlist. When only the <li> tag apears, bullets apear, but for some reason the <ol> tag has no effect on the <li> when I put it in the [print ("<li><tr><td width=100%> $dot_name</td></tr>");]

  6. #6
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have the order messed up a bit. Your ordered list should be inside your table's <td></td>. I think it should look like this instead:
    Code:
    print ("<tr><td width=100%><ol><li> $dot_name</li></ol></td></tr>"
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  7. #7
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Newbster: can you show the HTML output you are expecting? Looking at vinyl-junkie's answer, you are going to be getting some really ugly HTML out of PHP.

    The numbers will only turn up if you have some semi-valid HTML going on. Best results will be if your code looks like this:

    HTML Code:
    <ol>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
    </ol>
    Douglas
    Hello World

  8. #8
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Oregon
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Opps, sorry I posted that wrong, but I did try it that way and it still showed up as bullets instead of an ordered list...

  9. #9
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The coed above give this with default style sheets:

    Code:
    1. Item 
    2. Item 
    3. Item
    I can only think of two things:
    1) your HTML is invalid
    2) you have a stylesheet set to make <ol> look like <ul>

    Douglas
    Hello World

  10. #10
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Oregon
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    Newbster: can you show the HTML output you are expecting? Looking at vinyl-junkie's answer, you are going to be getting some really ugly HTML out of PHP.

    The numbers will only turn up if you have some semi-valid HTML going on. Best results will be if your code looks like this:

    HTML Code:
    <ol>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
    </ol>
    Douglas
    Well, I do think its the php coding part because when I just to insert the code like above, it shows as numbers... But then how would I make it so that it would get the values and make it into an ordered list?

  11. #11
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Newbster
    Well, I do think its the php coding part because when I just to insert the code like above, it shows as numbers... But then how would I make it so that it would get the values and make it into an ordered list?
    Load up the PHP page in IE that is giving you the bad output, right click "View Source" and copy out the bit for the list. Lets see what it looks like.

    Douglas
    Hello World

  12. #12
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Oregon
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    The coed above give this with default style sheets:

    Code:
    1. Item 
    2. Item 
    3. Item
    I can only think of two things:
    1) your HTML is invalid
    2) you have a stylesheet set to make <ol> look like <ul>

    Douglas
    Thats what I thought too, but I checked both, in my styles sheet, I never put in <ul> or <ol> tag and I checked my HTML, and it is not invalid...

  13. #13
    SitePoint Guru augathra's Avatar
    Join Date
    Jul 2004
    Location
    united states
    Posts
    826
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should post your full script, and then post the output with "View Source". Obviously something is wrong with the code, and it's a little easier if you give us the code.

  14. #14
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Oregon
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whole php code:
    PHP Code:
    <html>
    <head>
    <?php include "config.php"?>
    <link rel=stylesheet type=text/css href=styles/mediev.css>
    </head>
    <body>

    <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <?
    $xp 
    mysql_query("SELECT * FROM mediev_test ORDER BY xp DESC LIMIT 5");
    print (
    "<ol>");
    if (
    $row mysql_fetch_array($xp)) {
    do {
    $xp_name $row["xp"];
    print (
    "<tr><td width=\"100%\"><li> $xp_name </li></td></tr>");
    } while (
    $row mysql_fetch_array($xp));
    }
    print (
    "</ol>");
    ?>
    </table>
    </body>
    </html>
    Heres the view sorce it still apears with bullets...
    Code:
    <html>
    <head>
    <link rel=stylesheet type=text/css href=styles/mediev.css>
    </head>
    <body>
    
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <ol><tr><td width="100%"><li> 100005 </li></td></tr><tr><td width="100%"><li> 890 </li></td></tr><tr><td width="100%"><li> 401 </li></td></tr><tr><td width="100%"><li> 300 </li></td></tr><tr><td width="100%"><li> 200 </li></td></tr></ol></table></body>
    </html>

  15. #15
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Oregon
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey I think I got it, The table part of the code was messing up the list thing, I don't know why but I took it out and the ordered list showed up. Thanks for all the help guys!

  16. #16
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Newbster
    Hey I think I got it, The table part of the code was messing up the list thing, I don't know why but I took it out and the ordered list showed up. Thanks for all the help guys!
    That's why we asked to see the whole thing

    <table><ol><tr><td><li>Item</li></td></tr></ol></table>

    is invaliv HTML!

    It is either a table:
    <table><tr><td>Cell</td></tr></table>

    Or a list:
    <ol><li>Item</li></ol>

    The only thing that can go in a <table> tag is a: <tr>. (Well... not exactly, check the spec if you want better info)

    And the only thing that can go in an <ol> tag is an: <li>.

    If you do other things, you'll probably end up hitting problems sooner or later!

    Douglas
    Hello World


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
  •