require_once('include.php'); ?>
echo"
Newspaper :: $game
";
if(!isset($_GET['art'])){
echo "
";
if($_POST['post'] == 'Post New Article'){
$tit = $_POST['title'];
$text = $_POST['artigo'];
$datatempo = date("Y-m-d H:i:s");
mysqli_query($con, "INSERT INTO artigos
(titulo, autorid, user, diahpublo, datatempo, texto)
VALUES
('$tit', '$id', '$usar', '$diajogo', '$datatempo', '$text')");
$artigo = mysqli_query($con, "SELECT id FROM artigos WHERE titulo='$tit' AND autorid='$id' ORDER BY diahpublo,datatempo DESC LIMIT 1");
while($row=mysqli_fetch_array($artigo)){
$ida = $row['id'];
echo "New article created. You can acess it from here";
}
}
}
else
{
$art = $_GET['art'];
if(isset($_POST['vot'])){
$voto = mysqli_query($con, "SELECT count(idc) AS total FROM votos WHERE idc='$id' AND ida='$art'");
while($row=mysqli_fetch_array($voto)){
$total = $row['total'];
}
if($total == 0){
mysqli_query($con, "INSERT INTO votos (idc, ida) VALUES ('$id', '$art')");
mysqli_query($con, "UPDATE artigos SET votos=votos+1 WHERE id='$art'");
}
}
$artigo = mysqli_query($con, "SELECT * FROM artigos WHERE id='$art'");
while($row=mysqli_fetch_array($artigo)){
$ida = $row['autorid'];
$tit = $row['titulo'];
$tex = $row['texto'];
$vot = $row['votos'];
$aut = $row['user'];
$diahp = $row['diahpublo'];
$datetime = $row['datatempo'];
$titulo = $tit;
$tex = nl2br($tex);
echo "$aut | day $diahp | at $datetime
$tex
";
}
}
?>