really need help with this little bit of php and css

Discussion in 'Programming' started by Kurt Whittingham, Jul 26, 2012.

  1. #1
    i am pulling 10 of the latest entrys into my database, and i want them to display like so :

    new ktm50 date
    new ktm65 date

    but it doesnt display like that it shows like this (but the date is higher than the new ktm)

    new ktm50 date

    new ktm65 date

    this is the css
    #bodycontatiner {
        margin-top: 0px;
        margin-bottom: 0px;
        margin-left: auto;
        margin-right: auto;
        padding: 5px;
        width: 80%;
        overflow: auto;
        background-color: white;
    }
    #main {
        margin-top: 0px;
        margin-bottom: 0px;
        margin-left: auto;
        margin-right: auto;
        padding: -5px;
        width: 70%;
        min-height: 500px;
        background-color: white;
        float: left;
    }
    #latestcontent {
        width: 50%;
        max-height: 50px;
    }
    #newestpostleft {
        margin-top: 0px;
        margin-bottom: 0px;
        float: left;
        width: 70%;
    }
    #newestpostright {
        margin-top: 0px;
        margin-bottom: 0px;
        float: right;
        width: 30%;
    }
    #rightbar {
        margin-top: 0px;
        margin-bottom: 0px;
        margin-left: auto;
        margin-right: auto;
        padding: 0px;
        width: 30%;
        vertical-align:text-top;
        min-height: 200px;
        float: left;
    }
    #adv {
        border:2px solid #A9A9A9;
    }
    #follow {
        margin-top: 0px;
        margin-bottom: 0px;
        margin-left: auto;
        margin-right: auto;
        padding: 2px;
        padding-top: -2px;
        border:2px solid #A9A9A9;
        text-align:center;
        float: left;
        width: 335px;
    }
    Code (markup):

    and this is the html/php
    <html>
    <head>
    
    <title>Motor Bike Central</title>
    <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    
    <body>
    <?php include 'header.php'; ?>
        
        <div id="bodycontatiner">
            <div id="main">
            
                <div id="latestcontent">
            
                    <?php require('connect.php');
                    
                    $result = mysql_query("SELECT * FROM articles ORDER BY article_id DESC LIMIT 10")
                    or die(mysql_error());  
                    // keeps getting the next row until there are no more to get
                    while($row = mysql_fetch_array( $result )) {
                    // Print out the contents of each row into a table
                    echo "<div>";
                    echo "<div id='newestpostleft'>"; 
                    echo '<p><a style="font-size: 10px" href="'. $row['url'] .'">'. $row['article_name'] .'</a>'; echo "</div><div id='newestpostright'>";    echo '<p style="font-size: 10px">'; echo $row['posted'];    echo "</div>";
                    // author + date
                    echo "</div>";
                    
                    }
    
                    ?>
                </div>
            
            </div>
            
    
        
    <?php include 'rightbar.php'; ?>
    <?php include 'footer.php'; ?>
    HTML:
     
    Kurt Whittingham, Jul 26, 2012 IP
  2. shubhamm

    shubhamm Member

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    add margin in
    
    echo '<p style="margin:0;"><a style="font-size: 10px" href="#">article name</a>'; echo "</div><div id='newestpostright'>";    echo '<p style="font-size: 10px;margin:0;">'; 
    Code (markup):
    this line i have modify this code to work without db but result is same
     
    shubhamm, Jul 28, 2012 IP
  3. Kurt Whittingham

    Kurt Whittingham Member

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #3
    i only added the style margin part into both.. and now they links dont work?
     
    Kurt Whittingham, Jul 28, 2012 IP
  4. shubhamm

    shubhamm Member

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    <html>
    <head>
    
    <title>Motor Bike Central</title>
    <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    
    <body>
    <?php include 'header.php'; ?>
       
        <div id="bodycontatiner">
            <div id="main">
           
                <div id="latestcontent">
           
                    <?php require('connect.php');
                   
                   $result = mysql_query("SELECT * FROM articles ORDER BY article_id DESC LIMIT 10")
                   or die(mysql_error());  
                   // keeps getting the next row until there are no more to get
                   while($row = mysql_fetch_array( $result )) {
                   // Print out the contents of each row into a table
                   echo "<div>";
                    echo "<div id='newestpostleft'>";
                    echo '<p><a style="font-size: 10px;margin:0" href="'. $row['url'] .'">'. $row['article_name'] .'</a>'; echo "</div><div id='newestpostright'>";    echo '<p style="font-size: 10px;margin:0">'; echo $row['posted'];    echo "</div>";
                    // author + date
                    echo "</div>";
                   
                    }
    
                    ?>
                </div>
           
            </div>
           
    
       
    <?php include 'rightbar.php'; ?>
    <?php include 'footer.php'; ?>
    Code (markup):
    Show me a live example i will check its working on Localhost for me

    Edit : add the ";" after margin
     
    Last edited: Jul 28, 2012
    shubhamm, Jul 28, 2012 IP
  5. Kurt Whittingham

    Kurt Whittingham Member

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #5
    Kurt Whittingham, Jul 28, 2012 IP