Skip to content

Instantly share code, notes, and snippets.

@nikartx
Last active October 12, 2015 20:46
Show Gist options
  • Save nikartx/05bb65fe3459bf985603 to your computer and use it in GitHub Desktop.
Save nikartx/05bb65fe3459bf985603 to your computer and use it in GitHub Desktop.
Fish html page with news from site DB
<!doctype html>
<html>
<head>
<meta charset="utf8">
<title> Site news </title>
</head>
<body>
<?php
$connection = mysql_connect("127.0.0.1", "root", "");
$db = mysql_select_db("DataBaseName");
// mysql_set_charset("utf8");
if(!$connection || !$db) {
echo "Error! No connection with DB.";
exit(mysql_error());
}
$result = mysql_query("SELECT * FROM news");
mysql_close();
while ( $mass = mysql_fetch_assoc($result) )
{?>
<h1> <?php echo $mass['title']; ?> </h1>
<img src="<?php echo $mass['img']; ?>" />
<p> <?php echo $mass['description']; ?> </p>
<p> Date: <?php echo $mass['date']; ?> </p>
<hr/>
<?php }?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment