Boxerman Posted October 2, 2008 Share Posted October 2, 2008 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 https://forums.phpfreaks.com/topic/126812-news-on-top/ Share on other sites More sharing options...
waynew Posted October 2, 2008 Share Posted October 2, 2008 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 https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-655930 Share on other sites More sharing options...
dennismonsewicz Posted October 2, 2008 Share Posted October 2, 2008 this line will not validate if you run it through a validator: echo '<a href="story.php?id='.$row['story_id'].'"><h3>'.$row['title_of_story'].'</h3></a>'; the correction is this: echo '<h3><a href="story.php?id='.$row['story_id'].'">'.$row['title_of_story'].'</a></h3>'; Link to comment https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-655931 Share on other sites More sharing options...
waynew Posted October 2, 2008 Share Posted October 2, 2008 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 https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-655932 Share on other sites More sharing options...
dennismonsewicz Posted October 2, 2008 Share Posted October 2, 2008 if you are wanting this to validate and even look right, in some cases, make note of the correction i fixed in your code Link to comment https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-655934 Share on other sites More sharing options...
waynew Posted October 2, 2008 Share Posted October 2, 2008 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 https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-655942 Share on other sites More sharing options...
dennismonsewicz Posted October 2, 2008 Share Posted October 2, 2008 Thank you wayne LOL... wasn't trying to get recognize necessarily just didn't know if you needed this to validate. sorry for sounding "pushy" Link to comment https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-655944 Share on other sites More sharing options...
waynew Posted October 2, 2008 Share Posted October 2, 2008 Well I've learned something new! I now know myself not place them inside <a> tags. Although I usually don't do it! Link to comment https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-655949 Share on other sites More sharing options...
Boxerman Posted October 3, 2008 Author Share Posted October 3, 2008 Guys all of your are top stuff thanks alot! the query i dont understand!? how do i do that? Link to comment https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-656210 Share on other sites More sharing options...
trq Posted October 3, 2008 Share Posted October 3, 2008 We need to see the line containing mysql_query() Link to comment https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-656212 Share on other sites More sharing options...
Boxerman Posted October 3, 2008 Author Share Posted October 3, 2008 so how would i query to get that? if you give me a basic one i can see if i can work it out? Link to comment https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-656213 Share on other sites More sharing options...
Boxerman Posted October 3, 2008 Author Share Posted October 3, 2008 in the script above it says... story.php?id= where a user clicks the image to display.. id=1 how do i get it to show full story? Link to comment https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-656226 Share on other sites More sharing options...
Boxerman Posted October 3, 2008 Author Share Posted October 3, 2008 ive done the query what abou thte story id so it display full story when clicked? Link to comment https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-656487 Share on other sites More sharing options...
Kingy Posted October 3, 2008 Share Posted October 3, 2008 I believe they are talking about you showing them the query you are using to select the news form the DB eg: mysql_query("SELECT * FROM news"); Link to comment https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-656657 Share on other sites More sharing options...
Boxerman Posted October 4, 2008 Author Share Posted October 4, 2008 $result = mysql_query("SELECT * FROM news ORDER BY id DESC"); Link to comment https://forums.phpfreaks.com/topic/126812-news-on-top/#findComment-657128 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.