Система за новини – Част Втора
продължаваме с системата 🙂
ето го и addcomment.php
<?php include ("config.php"); ?>
<!--
Web-Journal By jooorooo@data.bg
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $CHARSET ?>">
<title><?php echo $TITLE ?></title>
<LINK href="css/css.css" type=text/css rel=stylesheet>
<script src="css/smile.js">
</script>
<script src="css/max.js">
</script>
</head>
<body>
<table width="900" border="0" cellspacing="3" cellpadding="0">
<tr>
<td><img src="img/logo.jpg" width="180" height="60"></td>
<td align="center"></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> </td>
<td height="19" align="right" background="img/h_gr2.gif" class=text> </td>
</tr>
<tr>
<td align="right" colspan="2" class="nav" id="lineLRBs">
<table cellpadding="10" cellspacing="0" width="100%">
<tr>
<td width="55%"> </td>
<td align="right" width="45%">
<form method="GET" action="search.php">
<table cellpadding="0" cellspacing="0" width="300px" >
<tr>
<td align="right" width="200px"><input class=commentbox type="text" name="Search" size="30"></td>
<td align="right" width="100px"><input class=commentbox type="submit" value="<?php echo $SEARCH ?>" name="Submit"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="15" colspan="2"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" width="199">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> <?php echo $MENU ?></td>
</tr>
<tr>
<td id="lineLRBs" class="nav"> <strong><a href="index.php"><?php echo $HOME ?></a></strong></td>
</tr>
<tr>
<td id="lineLRBs" class="nav"> <strong><a href="archive.php"><?php echo $ARCHIVE ?></a></strong></td>
</tr>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> <?php echo $CATEGORIES ?></td>
</tr>
<?php
mysql_connect($server, $dbusername, $dbpassword)or die("Сайтът не може да се свърже към базата данни");
@mysql_select_db($db_name) or die("Грешна база данни");
$query="SELECT * FROM cat ORDER BY cats ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$cats=mysql_result($result,$i,"cats");
echo "<tr><td id=lineLRBs class=nav> <strong><a href=catview.php?cats=$cats>$cats</a></strong></td></tr>";
$i++;
}
?>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> <?php echo $ANKETA ?></td>
</tr>
<tr>
<td id="lineLRBs" class="nav">
<?php
$ip= getenv("REMOTE_ADDR");
$sql="SELECT * FROM vaprosi ORDER BY v_id DESC LIMIT 0 , 1";
$rez=mysql_query($sql,$link);
$red=mysql_fetch_array($rez);
$vapros=$red['vapros'];
$v_id=$red['v_id'];
$sql1="SELECT * FROM ip WHERE `uip` LIKE '$ip' AND `v_id` LIKE '$v_id' ";
$rez1=mysql_query($sql1,$link);
$chekip=mysql_num_rows($rez1);
$sql1="SELECT * FROM ip WHERE `v_id` LIKE '$v_id'";
$rez1=mysql_query($sql1,$link);
$broiip=mysql_num_rows($rez1);
echo $vapros."<br /><br />";
if($chekip==0){
$sql="SELECT * FROM otgovori WHERE v_id LIKE '$v_id'";
$rez=mysql_query($sql,$link);
echo"<form action=\"sendvote.php\" method=\"POST\" >";
while($red=mysql_fetch_array($rez)){
echo "<input type=\"radio\" name=\"vote\" value=\"".$red['o_id']."\" />".$red['otgovor']."<br />";
}
echo"<center><br><input type=\"submit\" value=\"Гласувай\" /></center></form>";
}
else{
$sql="SELECT * FROM otgovori WHERE v_id LIKE '$v_id'";
$rez=mysql_query($sql,$link);
while($red=mysql_fetch_array($rez)){
echo "<table width=100%><tr>
<td width=130px>".$red['otgovor']."</td>
<td width=30px>".$red['rezultat']."</td>
</tr>
</table>";
}
}
mysql_close($link);
?>
</td>
</tr>
</table>
</td>
<td valign="top" width="692">
<table id=lineLRBs class=nav border=0 cellpadding=0 cellspacing=0 width=100%>
<?php
mysql_connect($server, $dbusername, $dbpassword)or die("Сайтът не може да се свърже към базата данни");
@mysql_select_db($db_name) or die("Грешна база данни");
$id_news = $_GET['id_news'];
$archive="SELECT * FROM news WHERE id_news = '$id_news' ORDER BY godina DESC";
$godinass=mysql_query($archive);
$num=mysql_numrows($godinass);
mysql_close();
$i=0;
while ($i < $num) {
$id_news=mysql_result($godinass,$i,"id_news");
$title=mysql_result($godinass,$i,"title");
$chas=mysql_result($godinass,$i,"chas");
$minuti=mysql_result($godinass,$i,"minuti");
$den=mysql_result($godinass,$i,"den");
$mesec=mysql_result($godinass,$i,"mesec");
$godina=mysql_result($godinass,$i,"godina");
$cats=mysql_result($godinass,$i,"cats");
$newstext=mysql_result($godinass,$i,"newstext");
echo "<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<td class=text height=19 background=img/h_gr2.gif> <strong><a href=fullnews.php?id_news=$id_news>$title</a></strong></td>
</tr>
<tr>
<td>
<table id=lineLRBs class=nav border=0 cellpadding=0 cellspacing=0 width=100%>
<tr>
<td height=25px id=lineBottom width=33%> Категория: <strong><a href=catview.php?cats=$cats>$cats</a></strong></td>
<td height=25px id=lineBottom width=33%> </td>
<td height=25px id=lineBottom width=34%> <strong>$chas:$minuti - $den/$mesec/$godina</strong></td>
</tr>
<tr>
<td id=lineBottom width=100% colspan=3><div><table cellpadding=5 width=100%>
<tr>
<td width=100%><p align=justify>$newstext</p></td>
</tr>
</table></div></td>
</tr>
<tr>
<td height=25px width=33%> <strong><a href=addcomment.php?id_news=$id_news>Коментари</a></strong></td>
<td height=25px width=33%> </td>
<td height=25px width=34%> <strong><a href=fullnews.php?id_news=$id_news>Прочети цялата новина</a></strong></a></td>
</tr>
</table>";
echo "<br>";
$i++;
}
?>
</table>
<br>
<?php
mysql_connect($server, $dbusername, $dbpassword)or die("Сайтът не може да се свърже към базата данни");
@mysql_select_db($db_name) or die("Грешна база данни");
$pageNum = 1;
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
$id_news=$_GET['id_news'];
$query = "SELECT COUNT(id_com) AS numrows FROM comments WHERE id_news = '$id_news' ";
$result = mysql_query($query) or die('Error, query failed1');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
$redove = ($pageNum - 1) * $broinastranicacom;
$id_news=$_GET['id_news'];
$querys = " SELECT * FROM comments WHERE id_news = '$id_news' ORDER BY id_com DESC LIMIT $redove, $broinastranicacom";
$results = mysql_query($querys) or die('Error, query failed2');
while($row = mysql_fetch_array($results))
{
$id_news=$row[id_news];
$username=$row[username];
$minuti=$row[minuti];
$chas=$row[chas];
$den=$row[den];
$mesec=$row[mesec];
$godina=$row[godina];
$comment=$row[comment];
echo "<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<td class=text height=19 background=img/h_gr2.gif> Добавил: <strong>".$username."</strong></td>
</tr>
<tr>
<td>
<table id=lineLRBs class=nav border=0 cellpadding=0 cellspacing=0 width=100%>
<tr>
<td height=25px id=lineBottom width=100%> <strong>".$chas.":".$minuti." - ".$den."/".$mesec."/".$godina."</strong></td>
</tr>
<tr>
<td width=100%><div><table cellpadding=5 width=100%>
<tr>
<td width=100%><p align=justify>".$comment."</p></td>
</tr>
</table></div></td>
</tr>
</table>";
echo "<br>";
}
if ($numrows<1)
{echo "<center><b>Няма добавени коментари за ".$title."</b></center><br>";}
$maxPage = ceil($numrows/$broinastranicacom);
$self = $_SERVER['PHP_SELF'];
$nomeranastranici = '';
echo '<center><font face="Tahoma" style="font-size: 8pt">Страници:</font> ';
for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
{
$nomeranastranici .= "<font face=\"Tahoma\" style=\"font-size: 8pt\">$page</font>";
}
else
{
$nomeranastranici .= " <font face=\"Tahoma\" style=\"font-size: 8pt\"><a href=\"$self?id_news=$id_news&page=$page\">$page</a> </font>";
}
}
if ($pageNum > 1)
{
$page = $pageNum - 1;
$predishna = "<font face=\"Tahoma\" style=\"font-size: 8pt\"><a href=\"$self?id_news=$id_news&page=$page\">[<<<<<]</a> </font>";
$parva = "<font face=\"Tahoma\" style=\"font-size: 8pt\"><a href=\"$self?id_news=$id_news&page=1\">[първа]</a> </font>";
}
else
{
$predishna = ' ';
$parva = ' ';
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$sledvashta = "<font face=\"Tahoma\" style=\"font-size: 8pt\"><a href=\"$self?id_news=$id_news&page=$page\">[>>>>>]</a> </font>";
$posledna = "<font face=\"Tahoma\" style=\"font-size: 8pt\"><a href=\"$self?id_news=$id_news&page=$maxPage\">[последна]</a></font>";
}
else
{
$sledvashta = ' ';
$posledna = ' ';
}
echo $parva . $predishna . $nomeranastranici . $sledvashta . $posledna;
?>
<br><br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> <?php echo $ADDCOMMENT ?></td>
</tr>
<tr>
<td id="lineLRBs" class="nav">
<?php
$a = rand(0,9);
$b = rand(0,9);
$c = rand(0,9);
$d = rand(0,9);
$random = "$a"."$b"."$c"."$d";
?>
<form action=addcomment.php?id_news=<?php echo $id_news ?> method=post name=form>
<input type="hidden" value="<?php print(date("i")); ?>" name="minuti">
<input type="hidden" value="<?php print(date("G")); ?>" name="chas">
<input type="hidden" value="<?php print(date("j")); ?>" name="den">
<input type="hidden" value="<?php print(date("F")); ?>" name="mesec">
<input type="hidden" value="<?php print(date("Y")); ?>" name="godina">
<input type="hidden" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" name="ip">
<input type="hidden" value="<?php echo $id_news ?>" name="id_news">
<input type="hidden" value="<?php echo $title ?>" name="title">
<table border=0>
<tr>
<td>Име</td>
<td><input class=commentbox name=username type=text class=form size="20"></td>
</tr>
<tr>
<td>Email</td>
<td><input class=commentbox name=email type=text class=form size="20"></td>
</tr>
<tr>
<td>Секретен код</td>
<td><input class=commentbox name=code1 type=text id=code1 value=<?php echo $random ?> class=form></td>
</tr>
<tr>
<td>Повтори кода </td>
<td><input class=commentbox name=code2 type=text class=form size="20"></td>
</tr>
<tr>
<td></td>
<td>
<a href="javascript:areatext(':)');"><img border=0 src=img/smile.gif></a>
<a href="javascript:areatext(':D');"><img border=0 src=img/happy.gif></a>
<a href="javascript:areatext(':(');"><img border=0 src=img/sad.gif></a>
<a href="javascript:areatext(':p');"><img border=0 src=img/tongue.gif></a>
<a href="javascript:areatext(':o');"><img border=0 src=img/bored.gif></a>
<a href="javascript:areatext('8)');"><img border=0 src=img/cool.gif></a>
</td>
</tr>
<tr>
<td>Коментар</td>
<td><textarea rows=7 class=commentbox name=comment cols=60 type=text onKeyDown="CountLeft(this.form.comment,this.form.left,<?php echo $broicom ?>);"
onKeyUp="CountLeft(this.form.comment,this.form.left,<?php echo $broicom ?>);"></textarea><br>Остават още <input class=commentbox readonly type="text" name="left" size=3 maxlength=3 value="<?php echo $broicom ?>"> символа</td>
</tr>
<tr>
<td> </td>
<td><input type=submit name=Submit value=Добави class=form></td>
</tr>
</table>
</form>
<?php
if($_POST['Submit']){
$minuti = $_POST['minuti'];
$chas = $_POST['chas'];
$den = $_POST['den'];
$mesec = $_POST['mesec'];
$godina = $_POST['godina'];
$username = $_POST['username'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$code1 = $_POST['code1'];
$code2 = $_POST['code2'];
if(empty($username)){
echo "Моля, въведете име";
die();
};
if(empty($email)){
echo "Моля въведете email";
die();
};
if(empty($comment)){
echo "Моля, въведете коментар";
};
if($code1 !== $code2){
echo "Кода не съвпада";
die();
};
$comment = str_replace("<", "<", $comment);
$comment = str_replace(">", ">", $comment);
$comment = str_replace("\n", "<br>", $comment);
$comment = str_replace(":)", "<img src=img/smile.gif>", $comment);
$comment = str_replace(":D", "<img src=img/happy.gif>", $comment);
$comment = str_replace(":(", "<img src=img/sad.gif>", $comment);
$comment = str_replace(":p", "<img src=img/tongue.gif>", $comment);
$comment = str_replace(":o", "<img src=img/bored.gif>", $comment);
$comment = str_replace("8)", "<img src=img/cool.gif>", $comment);
mysql_connect($server, $dbusername, $dbpassword)or die("Сайтът не може да се свърже към базата данни");
@mysql_select_db($db_name) or die("Грешна база данни");
$query = "INSERT INTO `comments` ( `id_com` , `id_news` , `username` , `email`, `minuti`, `chas`, `den`, `mesec`, `godina`, `ip`, `comment`, `title`)
VALUES (
'NULL', '$id_news', '$username', '$email', '$minuti', '$chas', '$den', '$mesec', '$godina', '$ip', '$comment', '$title'
);";
$ok = mysql_query($query);
if($ok){
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=addcomment.php?id_news=$id_news\">";
}else{
echo "Възникна грешка";
}
};
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</body>
</html>следва archive.php
<?php include ("config.php"); ?>
<!--
Web-Journal By jooorooo@data.bg
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $CHARSET ?>">
<title><?php echo $TITLE ?></title>
<LINK href="css/css.css" type=text/css rel=stylesheet>
</head>
<body>
<table width="900" border="0" cellspacing="3" cellpadding="0">
<tr>
<td><img src="img/logo.jpg" width="180" height="60"></td>
<td align="center"></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> </td>
<td height="19" align="right" background="img/h_gr2.gif" class=text> </td>
</tr>
<tr>
<td align="right" colspan="2" class="nav" id="lineLRBs">
<table cellpadding="10" cellspacing="0" width="100%">
<tr>
<td width="55%"> </td>
<td align="right" width="45%">
<form method="GET" action="search.php">
<table cellpadding="0" cellspacing="0" width="300px" >
<tr>
<td align="right" width="200px"><input class=commentbox type="text" name="Search" size="30"></td>
<td align="right" width="100px"><input class=commentbox type="submit" value="<?php echo $SEARCH ?>" name="Submit"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="15" colspan="2"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" width="199">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> <?php echo $MENU ?></td>
</tr>
<tr>
<td id="lineLRBs" class="nav"> <strong><a href="index.php"><?php echo $HOME ?></a></strong></td>
</tr>
<tr>
<td id="lineLRBs" class="nav"> <strong><a href="archive.php"><?php echo $ARCHIVE ?></a></strong></td>
</tr>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> <?php echo $CATEGORIES ?></td>
</tr>
<?php
mysql_connect($server, $dbusername, $dbpassword)or die("Сайтът не може да се свърже към базата данни");
@mysql_select_db($db_name) or die("Грешна база данни");
$query="SELECT * FROM cat ORDER BY cats ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$cats=mysql_result($result,$i,"cats");
echo "<tr><td id=lineLRBs class=nav> <strong><a href=catview.php?cats=$cats>$cats</a></strong></td></tr>";
$i++;
}
?>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> <?php echo $ANKETA ?></td>
</tr>
<tr>
<td id="lineLRBs" class="nav">
<?php
$ip= getenv("REMOTE_ADDR");
$sql="SELECT * FROM vaprosi ORDER BY v_id DESC LIMIT 0 , 1";
$rez=mysql_query($sql,$link);
$red=mysql_fetch_array($rez);
$vapros=$red['vapros'];
$v_id=$red['v_id'];
$sql1="SELECT * FROM ip WHERE `uip` LIKE '$ip' AND `v_id` LIKE '$v_id' ";
$rez1=mysql_query($sql1,$link);
$chekip=mysql_num_rows($rez1);
$sql1="SELECT * FROM ip WHERE `v_id` LIKE '$v_id'";
$rez1=mysql_query($sql1,$link);
$broiip=mysql_num_rows($rez1);
echo $vapros."<br /><br />";
if($chekip==0){
$sql="SELECT * FROM otgovori WHERE v_id LIKE '$v_id'";
$rez=mysql_query($sql,$link);
echo"<form action=\"sendvote.php\" method=\"POST\" >";
while($red=mysql_fetch_array($rez)){
echo "<input type=\"radio\" name=\"vote\" value=\"".$red['o_id']."\" />".$red['otgovor']."<br />";
}
echo"<center><br><input type=\"submit\" value=\"Гласувай\" /></center></form>";
}
else{
$sql="SELECT * FROM otgovori WHERE v_id LIKE '$v_id'";
$rez=mysql_query($sql,$link);
while($red=mysql_fetch_array($rez)){
echo "<table width=100%><tr>
<td width=130px>".$red['otgovor']."</td>
<td width=30px>".$red['rezultat']."</td>
</tr>
</table>";
}
}
mysql_close($link);
?>
</td>
</tr>
</table>
</td>
<td valign="top" width="692">
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<td class=text height=19 background=img/h_gr2.gif> <strong>Архив:</strong></td>
</tr>
<tr>
<td>
<table id=lineLRBs class=nav border=0 cellpadding=0 cellspacing=0 width=100%>
<?php
mysql_connect($server, $dbusername, $dbpassword)or die("Сайтът не може да се свърже към базата данни");
@mysql_select_db($db_name) or die("Грешна база данни");
$archive="SELECT DISTINCT godina FROM news ORDER BY godina DESC";
$godinass=mysql_query($archive);
$num=mysql_numrows($godinass);
mysql_close();
$i=0;
while ($i < $num) {
$godina=mysql_result($godinass,$i,"godina");
echo "<tr>
<td height=25px id=lineBottom width=33%> Година: <strong><a href=year.php?godina=$godina>$godina</a></strong></td>
</tr>";
$i++;
}
?>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</body>
</html>catselect.php
<?php include ("config.php"); ?>
<!--
Web-Journal - Links Indexing By jooorooo@data.bg
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $CHARSET ?>">
<title><?php echo $TITLE ?></title>
<LINK href="css/css.css" type=text/css rel=stylesheet>
</head>
<body>
<table width="900" border="0" cellspacing="3" cellpadding="0">
<tr>
<td><img src="img/logo.jpg" width="180" height="60"></td>
<td align="center"></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> </td>
<td height="19" align="right" background="img/h_gr2.gif" class=text> </td>
</tr>
<tr>
<td align="right" colspan="2" class="nav" id="lineLRBs">
<table cellpadding="10" cellspacing="0" width="100%">
<tr>
<td width="55%"> </td>
<td align="right" width="45%">
<form method="GET" action="search.php">
<table cellpadding="0" cellspacing="0" width="300px" >
<tr>
<td align="right" width="200px"><input class=commentbox type="text" name="Search" size="30"></td>
<td align="right" width="100px"><input class=commentbox type="submit" value="<?php echo $SEARCH ?>" name="Submit"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="15" colspan="2"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" width="199">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> <?php echo $MENU ?></td>
</tr>
<tr>
<td id="lineLRBs" class="nav"> <strong><a href="index.php"><?php echo $HOME ?></a></strong></td>
</tr>
<tr>
<td id="lineLRBs" class="nav"> <strong><a href="archive.php"><?php echo $ARCHIVE ?></a></strong></td>
</tr>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> <?php echo $CATEGORIES ?></td>
</tr>
<?php
mysql_connect($server, $dbusername, $dbpassword)or die("Сайтът не може да се свърже към базата данни");
@mysql_select_db($db_name) or die("Грешна база данни");
$query="SELECT * FROM cat ORDER BY cats ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$cats=mysql_result($result,$i,"cats");
echo "<tr><td id=lineLRBs class=nav> <strong><a href=catview.php?cats=$cats>$cats</a></strong></td></tr>";
$i++;
}
?>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> <?php echo $ANKETA ?></td>
</tr>
<tr>
<td id="lineLRBs" class="nav">
<?php
$ip= getenv("REMOTE_ADDR");
$sql="SELECT * FROM vaprosi ORDER BY v_id DESC LIMIT 0 , 1";
$rez=mysql_query($sql,$link);
$red=mysql_fetch_array($rez);
$vapros=$red['vapros'];
$v_id=$red['v_id'];
$sql1="SELECT * FROM ip WHERE `uip` LIKE '$ip' AND `v_id` LIKE '$v_id' ";
$rez1=mysql_query($sql1,$link);
$chekip=mysql_num_rows($rez1);
$sql1="SELECT * FROM ip WHERE `v_id` LIKE '$v_id'";
$rez1=mysql_query($sql1,$link);
$broiip=mysql_num_rows($rez1);
echo $vapros."<br /><br />";
if($chekip==0){
$sql="SELECT * FROM otgovori WHERE v_id LIKE '$v_id'";
$rez=mysql_query($sql,$link);
echo"<form action=\"sendvote.php\" method=\"POST\" >";
while($red=mysql_fetch_array($rez)){
echo "<input type=\"radio\" name=\"vote\" value=\"".$red['o_id']."\" />".$red['otgovor']."<br />";
}
echo"<center><br><input type=\"submit\" value=\"Гласувай\" /></center></form>";
}
else{
$sql="SELECT * FROM otgovori WHERE v_id LIKE '$v_id'";
$rez=mysql_query($sql,$link);
while($red=mysql_fetch_array($rez)){
echo "<table width=100%><tr>
<td width=130px>".$red['otgovor']."</td>
<td width=30px>".$red['rezultat']."</td>
</tr>
</table>";
}
}
mysql_close($link);
?>
</td>
</tr>
</table>
</td>
<td valign="top" width="692">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class=text height="19" background="img/h_gr2.gif"> Категории:</td>
</tr>
<tr>
<td id="lineLRBs" bgcolor="#ddfbeb">
gsfdgdf gd g dgfd df
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</body>
</html>Следва продълцение 🙂


