Jump to content

News question


Boxerman

Recommended Posts

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!

 

Link to comment
Share on other sites


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.

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.