Jump to content

news on top?


Boxerman

Recommended Posts

Hi all..

 

this is my code

 

while($row = mysql_fetch_assoc($result)){

//Div for each news story
echo '<div style="width:400px; padding:3px; margin-bottom:8px; float:left;">';

//Div for image - change width according to thumbnail
echo '<div style="width:90px; float:left;">';
echo '<a href="story.php?id='.$row['story_id'].'">';
echo '<img src = "'.$row['directory'].'" style="border:2px #333333 solid;">';
echo '</a>';
echo '</div>';

//Div for news story text
echo '<div style="width:300px; float:right;">';
echo '<a href="story.php?id='.$row['story_id'].'"><h3>'.$row['title_of_story'].'</h3></a>';
echo $row['summary_of_story'];
echo '</div>';

echo '</div>';
}

 

the news display next to each other...

 

how do i get it to display iton top of each other and the newest at top?

 

thanks

Link to comment
Share on other sites

Hey you're using my code.  :)

 

while($row = mysql_fetch_assoc($result)){

    //Div for each news story
    echo '<div style="width:400px; padding:3px; margin-bottom:8px; float:left;">';
    
    //Div for image - change width according to thumbnail
    echo '<div style="width:90px; float:left;">';
    echo '<a href="story.php?id='.$row['story_id'].'">';
    echo '<img src = "'.$row['directory'].'" style="border:2px #333333 solid;">';
    echo '</a>';
    echo '</div>';
    
    //Div for news story text
    echo '<div style="width:300px; float:right;">';
    echo '<a href="story.php?id='.$row['story_id'].'"><h3>'.$row['title_of_story'].'</h3></a>';
    echo $row['summary_of_story'];
    echo '</div>';

echo '</div>';
}

 

I've fixed up the layout of the code for you. (I had wrote it into the forum textbox and couldn't use tabs.)

 

Anyway, could you show us the query that gets you your $result?

Link to comment
Share on other sites

Oh and to make them appear on top of each other, use this code:

 

while($row = mysql_fetch_assoc($result)){

   //Div for each news story
   echo '<div style="width:400px; padding:3px; margin-bottom:8px; float:left; clear:both;">';
   
   //Div for image - change width according to thumbnail
   echo '<div style="width:90px; float:left;">';
   echo '<a href="story.php?id='.$row['story_id'].'">';
   echo '<img src = "'.$row['directory'].'" style="border:2px #333333 solid;">';
   echo '</a>';
   echo '</div>';
   
   //Div for news story text
   echo '<div style="width:300px; float:right;">';
   echo '<a href="story.php?id='.$row['story_id'].'"><h3>'.$row['title_of_story'].'</h3></a>';
   echo $row['summary_of_story'];
   echo '</div>';

echo '</div>';
}

Link to comment
Share on other sites

Ok, make note of Dennis' contribution:

 

while($row = mysql_fetch_assoc($result)){

    //Div for each news story
    echo '<div style="width:400px; padding:3px; margin-bottom:8px; float:left; clear:both;">';
    
    //Div for image - change width according to thumbnail
    echo '<div style="width:90px; float:left;">';
    echo '<a href="story.php?id='.$row['story_id'].'">';
    echo '<img src = "'.$row['directory'].'" style="border:2px #333333 solid;">';
    echo '</a>';
    echo '</div>';
    
    //Div for news story text
    echo '<div style="width:300px; float:right;">';
    echo '<h3><a href="story.php?id='.$row['story_id'].'">'.$row['title_of_story'].'</a></h3>';
    echo $row['summary_of_story'];
    echo '</div>';

echo '</div>';
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.