<?php
$txt = $_GET["txt"];
if ($txt == "news") {

    include("../config.inc.php");

$sql = "SELECT * FROM TBLNEWS ORDER BY ID";

$sql_result = mysqli_query($connection, $sql);

if ($sql_result === false) {
    $status = 3;
    $tot = 0;
} else {
    $tot = mysqli_num_rows($sql_result);
}


    $num = $num + 1;

    if ($num >= $tot) {
        $num = 0;
    }

    $sql = "SELECT * FROM TBLNEWS ORDER BY ID ASC LIMIT " . $num . ",1";
if ($sql_result === false) {
    $status = 3;
    $tot = 0;
} else {
    $record = mysqli_fetch_array($sql_result);
}

}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>Documento senza titolo</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <?php  if (($txt == "news") and ($tot > 1)) {
        ?>
            <meta http-equiv="refresh" content="5;URL=txt_frame.php?txt=news&num=<?php  echo $num; ?>">
        <?php  } ?>
        <style type="text/css">
            <!--
            BODY {
                SCROLLBAR-FACE-COLOR: #CCCC99;
                SCROLLBAR-HIGHLIGHT-COLOR: #999966;  SCROLLBAR-SHADOW-COLOR: #999966;
                SCROLLBAR-3DLIGHT-COLOR: #CCCC99;  SCROLLBAR-ARROW-COLOR: #993333;
                SCROLLBAR-TRACK-COLOR: #FFFFFF;  SCROLLBAR-DARKSHADOW-COLOR: #000066;
            }
            -->
        </style>
    </head>

    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
        <?php  if ($txt == "benvenuti") {
 ?>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td><div><font color="#333366" size="2" face="Arial, Helvetica, sans-serif"><strong>Hotel Canturio<br></strong>
        								30 camere con ogni comfort:<br>
        								telefono, frigobar, phon, radio, <strong>sky TV e internet wireless compresi nel prezzo</strong>, aria condizionata regolabile.
        						Sale riunioni, ampio giardino,
        								parcheggio privato.</font>
                        </div></td>
                </tr>
            </table>
        <?php
        }
        if ($txt == "news") {
        ?>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td><div><font color="#333366" size="2" face="Arial, Helvetica, sans-serif"><strong><em><?php  echo $record["TITOLO"]; ?><br/>
                                    </em></strong><em><?php  echo str_replace("\n\r", "<br>", $record["TESTO"]); ?></em></font></div></td>
                </tr>
            </table>
        <?php
        }?>
</body>
</html>
