Hi All,
See the code
---------------------------------------------
CREATE TABLE IF NOT EXISTS `upload` (
`vid` int(10) NOT NULL,
`uid` int(10) NOT NULL,
`videos` varchar(50) NOT NULL,
`details` varchar(50) NOT NULL,
`date` date NOT NULL,
`points` int(11) NOT NULL,
PRIMARY KEY (`vid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
----------------------------------------------
viewvideos.php
<?php
include('connect.php');
$query = 'select * from upload';
$result = mysql_query($query);
if (!$result)
{
$message = 'ERROR:' . mysql_error();
return $message;
}
else
{
$i = 0;
echo '<html><body><table border=1 align=center><tr>';
while ($i < mysql_num_fields($result))
{
$meta = mysql_fetch_field($result, $i);
echo '<th>' . ucfirst($meta->name) . '</th>';
$i = $i + 1;
}
echo '<th>View</th>';
echo '';
echo '</tr>';
$i = 0;
while ($row = mysql_fetch_row($result))
{
echo '<tr>';
$count = count($row);
$y = 0;
$idval='1';
while ($y < $count)
{
$c_row = current($row);
if($y==0)
$idval=$c_row;
echo '<td>' . $c_row . '</td>';
next($row);
$y = $y + 1;
}
echo '<td><a href=videoupload/'.$idval.'.mp4>View Video</a></td>';
echo '<td><a href=rating.php?vid='.$idval.'&val=1><img width=30 height=30 src=images/star.jpg></a><a href=rating.php?vid='.$idval.'&val=2><img width=30 height=30 src=images/star.jpg></a><a href=rating.php?vid='.$idval.'&val=3><img width=30 height=30 src=images/star.jpg></a></td>';
echo '</tr>';
$i = $i + 1;
}
echo '</table></body></html>';
mysql_free_result($result);
}
mysql_close ($con);
?></center>
----------------------------------------------
rating.php
<?php
include('connect.php');
session_start();
$id=$_GET['vid'];
$val=$_GET['val'];
$sql="update upload set points=points+".$val." where vid='$id'";
echo $sql;
mysql_query($sql,$con);
header('location:viewvideos.php')
?>
See the code
---------------------------------------------
CREATE TABLE IF NOT EXISTS `upload` (
`vid` int(10) NOT NULL,
`uid` int(10) NOT NULL,
`videos` varchar(50) NOT NULL,
`details` varchar(50) NOT NULL,
`date` date NOT NULL,
`points` int(11) NOT NULL,
PRIMARY KEY (`vid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
----------------------------------------------
viewvideos.php
<?php
include('connect.php');
$query = 'select * from upload';
$result = mysql_query($query);
if (!$result)
{
$message = 'ERROR:' . mysql_error();
return $message;
}
else
{
$i = 0;
echo '<html><body><table border=1 align=center><tr>';
while ($i < mysql_num_fields($result))
{
$meta = mysql_fetch_field($result, $i);
echo '<th>' . ucfirst($meta->name) . '</th>';
$i = $i + 1;
}
echo '<th>View</th>';
echo '';
echo '</tr>';
$i = 0;
while ($row = mysql_fetch_row($result))
{
echo '<tr>';
$count = count($row);
$y = 0;
$idval='1';
while ($y < $count)
{
$c_row = current($row);
if($y==0)
$idval=$c_row;
echo '<td>' . $c_row . '</td>';
next($row);
$y = $y + 1;
}
echo '<td><a href=videoupload/'.$idval.'.mp4>View Video</a></td>';
echo '<td><a href=rating.php?vid='.$idval.'&val=1><img width=30 height=30 src=images/star.jpg></a><a href=rating.php?vid='.$idval.'&val=2><img width=30 height=30 src=images/star.jpg></a><a href=rating.php?vid='.$idval.'&val=3><img width=30 height=30 src=images/star.jpg></a></td>';
echo '</tr>';
$i = $i + 1;
}
echo '</table></body></html>';
mysql_free_result($result);
}
mysql_close ($con);
?></center>
----------------------------------------------
rating.php
<?php
include('connect.php');
session_start();
$id=$_GET['vid'];
$val=$_GET['val'];
$sql="update upload set points=points+".$val." where vid='$id'";
echo $sql;
mysql_query($sql,$con);
header('location:viewvideos.php')
?>