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
https://forums.phpfreaks.com/topic/126735-news-question/
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
https://forums.phpfreaks.com/topic/126735-news-question/#findComment-655512
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.