Skip to content

Instantly share code, notes, and snippets.

@nikartx
Last active October 12, 2015 20:46

Revisions

  1. nikartx revised this gist Oct 12, 2015. 1 changed file with 1 addition and 27 deletions.
    28 changes: 1 addition & 27 deletions home.php
    Original file line number Diff line number Diff line change
    @@ -7,33 +7,7 @@
    <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 }?>

    <div> <p>Спасибо за обращение! Ваше сообщение отправлено.</p> </div>
    </body>
  2. nikartx created this gist Jul 13, 2015.
    40 changes: 40 additions & 0 deletions home.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    <!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>