我制作了一个表单,它采用发布的 youtube 网址并将视频 ID 保存到数据库中。然后它从数据库中检索 ID,并将其插入 iframe。
只显示了 6 个视频,如何让用户在发布 6 个视频后,每次发布新视频时删除第一个视频?
基本上我希望它只有 6 个存储在数据库中,并且每次提交新帖子时,都会从数据库中删除第一个帖子。
这就是我现在所拥有的。
<div style="position:absolute; top:100px; left:830px; height:120px; width:680px; background-color:#d0d0d0; font-size:18px; color:#f1f1f1; text-align:center; z-index:0; overflow:none; color:#111; -moz-box-shadow:inset 0px 1px 0px 0px #ffffff;
-webkit-box-shadow:inset 0px 1px 0px 0px #ffffff;
box-shadow:inset 0px 1px 0px 0px #ffffff;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf) );
background:-moz-linear-gradient( center top, #ededed 5%, #dfdfdf 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf');
background-color:#ededed;
-moz-border-radius:6px;
-webkit-border-radius:6px;">
<form action="index.php" method="post">
<label for="song">What are you listening to?:</label><br>
<textarea name="song" onfocus="this.select()" id="song" rows="3" cols="71" style="text-align:center;">Post a youtube link here.</textarea>
<input type="submit" class="personal" value="Share" />
</form>
</div>
<?php
if ($_POST['song'])
{
$yvid = $_POST['song'];
parse_str( parse_url( $yvid, PHP_URL_QUERY ), $my_array_of_vars );
$yid = $my_array_of_vars['v'];
mysqli_query ($con,"INSERT INTO songs (user_name, ytid) VALUES ('".$_SESSION['user_name']."','".$yid."')");
}
?>
<div style="position:absolute; display:inline-block; background-color:transparent; height:560px; width:800px; left:810px; top:200px; border:0px; color:#dedede; overflow:auto;">
<?php
$result = mysqli_query($con,"SELECT * FROM songs WHERE user_name='".$_SESSION['user_name']."' ORDER BY time DESC LIMIT 6");
while($row = mysqli_fetch_array($result))
{
$ytsong = $row['ytid'];
$ytun = $row['user_name'];
$ytt = $row['time'];
echo "<p style=\"display:inline-block; height:220px; width:200px; text-align:center; padding:20px; border:0px; background-color:transparent;\">";
echo "<a class=\"vname\" href=\"http://s3v3nl3tt3r5.com/profile.php?username=$ytun\">$ytun</a> posted this at $ytt";
echo "<iframe style=\"display:inline-block;\" width=\"200\" height=\"200\" src=\"http://www.youtube.com/embed/$ytsong\" frameborder=\"0\" allowfullscreen></iframe>";
echo "<a class=\"personal\" href=\"http://www.youtube-mp3.org/get?video_id=$ytsong\" target=\"_blank\">Download Mp3</a>";
}
?>
</div>