SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Location
    Luton, UK
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with PHP & bullet points

    Hi All
    I have written this code (below) to show book titles in a small column on my web page. I have used <UL> to put a bullet point by each result - the problem is that I am getting a large white space, probably a paragraph, between each bullet point. Is there any way of closing up the gap between these points.

    Thanks for any help.
    -------------------
    <?
    include("fic.config.php");

    $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!");

    mysql_select_db("books");
    $query ="SELECT title FROM books";
    $result=mysql_query($query);
    $num_results=mysql_num_rows($result);
    echo "<font face=arial font size=2>Number of new stories:" . $num_results."<BR>";

    for($i = 0; $i <$num_results; $i++)
    {
    $row = mysql_fetch_array($result);
    echo "<font face=arial font size=2 color=#3333CC><UL><LI>"." ";
    echo "<font face=arial font size=-2 color=#000000>";
    echo htmlspecialchars(stripslashes($row["title"]));
    echo "</font></LI></UL>";

    }
    // close connection
    mysql_close($connection);
    ?>
    'As a computer, I find your faith in technology amusing'

  2. #2
    code addict Abstraction's Avatar
    Join Date
    Apr 2001
    Location
    Des Moines, IA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this out.

    PHP Code:
    <? 
    include("fic.config.php"); 

    $connection mysql_connect($hostname$user$pass) or die ("Unable to connect!"); 

    mysql_select_db("books"); 
    $query ="SELECT title FROM books"
    $result=mysql_query($query); 
    $num_results=mysql_num_rows($result); 
    echo 
    "<font face=arial font size=2>Number of new stories:" $num_results."<BR>"
    echo 
    "<UL>";

    for(
    $i 0$i <$num_results$i++) 

    $row mysql_fetch_array($result); 
    echo 
    "<font face=arial font size=2 color=#3333CC><LI>"." "
    echo 
    "<font face=arial font size=-2 color=#000000>"
    echo 
    htmlspecialchars(stripslashes($row["title"])); 
    echo 
    "</font></LI>"


    echo 
    "</UL>";

    // close connection 
    mysql_close($connection); 
    ?>

  3. #3
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep...

    You need to keep the <ul></ul> tags out of the looping. In effect, what you are doing is making a whole new unordered list for each element, when all you need to do is to make a new list item (<li>) for each element.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Location
    Luton, UK
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guy's I see my mistake now. Thanks so much for your help.
    Drew
    'As a computer, I find your faith in technology amusing'


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
  •