Boxerman Posted October 2, 2008 Share Posted October 2, 2008 Hi guys! Im just wondering... ive added news to my site... that will display in a table! <?php if (isset($_REQUEST['news'])){ echo "<form action=insertnews.php method=post>"; echo "<br>"; echo "ID <input type=text name=id />"; echo "<br>"; echo "Title <input type=text name=title />"; echo "<br>"; echo "story <input type=text name=story />"; echo "<br>"; echo "<br>"; echo "<input type=submit /></form>"; $con = mysql_connect("localhost","root","*****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("skatingnation", $con); $result = mysql_query("SELECT * FROM news"); echo "<table border='1'> <tr> <th>ID</th> <th>Title</th> <th>Story</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['title'] . "</td>"; echo "<td>" . $row['story'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "<br>"; echo "<br>"; echo "To Delete record enter the id number below"; echo "<br>"; echo "<form action=deletenews.php method=post>"; echo "<br>"; echo "ID <input type=text name=id />"; echo "<br>"; echo "<input type=submit /></form>"; mysql_close($con); } ?> how do i get it on the site to display as normal text with image on the left... that will add onto of each other like.. http://www.skateboardermag.com/skateboarder-news-features/news/ i want it like that really... so everytime i add it to databse it will display like that... and when you click the image it display full story?? Thanks all... the advice you give helps me lots! Quote Link to comment Share on other sites More sharing options...
waynew Posted October 2, 2008 Share Posted October 2, 2008 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>'; } Wrote that there so you'll need to test it and hack it to work with what you have. Also, can't be sure there are no errors. Mess around with it. Quote Link to comment Share on other sites More sharing options...
Boxerman Posted October 2, 2008 Author Share Posted October 2, 2008 where should i add this? and should i create a php file called story.php? 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.