Jump to content

Help getting mysql table info to output to the screen?


jeaker

Recommended Posts

I have been working on this code for 3 days now and i am stumped. It is supposed to go to my server and get the stuff in the table "news" and output the news articles that are in the database. I cannot for the life of me figure out what the problem may be. Any help would be greatly appriciated.
[code]<?php
$db_name = "newdb";
$table_name = "news";
$connection = @mysql_connect("db.blah.com", "johndoe", "blah")
or die(mysql_error());
$db = @mysql_select_db($db_name, $conection) or die(mysql_error());
$sql = "SELECT*FROM $table_name ORDER BY id";

$result = @mysql_query($sql, $connection) or die(mysql_error());

while ($row = mysql_fetch_array($result)) {

$id = $row['id'];
$title = $row['title'];
$content = $row['content'];
$timestamp = $row['timestamp'];


$display_block = "$title, $content, $contact, $timestamp";
}
?>
<html>
<head>
<title>Megalomaniacs News</title>
</head>
<body>
<h1>Megalomaniacs Inc. Articles</h1>
<?php echo "$display_block"; ?>
<p><a href="main.html">Return to Menu</a></p>
</body>
</html>[/code]

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.