<?php

/*CONEXAO COM O BANCO*/
include "Connections/config.php";
/*********************/

$message = "<div class=\"alert alert-primary\" id=\"flash-msg\"><h4><i class=\"icon fa fa-check\"></i>Items Updated!</h4></div>";
$rows = $db->query("SELECT COUNT(*) as count FROM sport");
$row = $rows->fetch_array();
$numRows = $row["count"];
if ($numRows == 0) {
    $db->query("INSERT INTO sport(id, title, url) VALUES('1', 'Default', 'https://www.tvsportguide.com/widget/5cc316f797659/?heading=Events&border_color=custom&autoscroll=0&custom_colors=')");
}
$res = $db->query("SELECT * \r\n\t\t\t\t  FROM sport \r\n\t\t\t\t  WHERE id='1'");
$row = $res->fetch_array();
$id = $row["id"];
$title = $row["title"];
$url = $row["url"];
if (isset($_POST["submit"])) {
    $db->query("UPDATE sport SET\ttitle='" . $_POST["title"] . "', " . "\r\n\t\t\t\t\t\t\t\t" . "url='" . $_POST["url"] . "'" . "\r\n\t\t\t\t\t\t" . "  WHERE " . "\r\n\t\t\t\t\t\t\t\t" . "id='1' ");
    header("Location: sports.php");
}
include "includes/header.php";
echo "       <div class=\"container-fluid\">\n\n          <!-- Page Heading -->\n          <h1 class=\"h3 mb-1 text-gray-800\">Sport Guide</h1>\n         \n          <!-- Content Row -->\n          <div class=\"row\">\n\n            <!-- First Column -->\n            <div class=\"col-lg-12\">\n\n              <!-- Custom codes -->\n                <div class=\"card border-left-primary shadow card shadow mb-4\">\n                <div class=\"card-header py-3\">\n                <h6 class=\"m-0 font-weight-bold text-primary\"><i class=\"fas fa-futbol\"></i> Edit Sport Guide</h6>\n                </div>\n                  <div class=\"card-body\">\n                    <form method=\"post\">\n                        <div class=\"form-group\">\n                          <label class=\"control-label\"for=\"title\">\n                              <strong>Title</strong>\n                            </label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"title\" value=\"" . $title . "\">" . "\n";
echo "                        </div>\n                            <div class=\"form-group \">\n                            <label class=\"control-label \" for=\"url\">\n                            <strong>URL</strong>\n                            </label>\n                            <div class=\"input-group\">\n";
echo "                            <input class=\"form-control\" id=\"url\" name=\"url\" value=\"" . $url . "\">" . "\n";
echo "                        </div>\n                      </div>\n                      <div class=\"form-group\">\n\t\t\t\t\t<br><button class=\"btn btn-success btn-icon-split\" name=\"submit\" type=\"submit\">\n                        <span class=\"icon text-white-50\"><i class=\"fas fa-check\"></i></span><span class=\"text\">Submit</span>\n                        </button>\n\t\t\t\t</form>\n\t\t\t\t</div>\n              </div>\n            </div>\n          </div>\n      </div>\n\t </div>\n    <br><br><br>\n";
include "includes/footer.php";
require "includes/boxbr.php";

?>