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 Quote Link to comment 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? Quote Link to comment 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>'; Quote Link to comment 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>'; } Quote Link to comment 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 Quote Link to comment 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>'; } Quote Link to comment 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" Quote Link to comment 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! Quote Link to comment 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? Quote Link to comment 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() Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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"); Quote Link to comment 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"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.