刷新PHP PHP并发布表单

时间:2014-11-28 23:35:06

标签: php mysql forms post iframe

我有一个选择框,当它选择时,它会刷新页面,导致iframe更新其链接。现在一切正常,除非我每次更改列表框的值都会刷新整个页面,而我只是寻找部分内容。

select和iframe,现在我将向您展示我的PHP,然后它可能会清除这种情况!

<?php
error_reporting(E_ALL ^ E_DEPRECATED);
$dbh = mysql_connect("host", "user", "pass");
mysql_select_db("database_name");
############END OF CONNECT SCRPIT#############################
$id = $_GET['id'];
######id as in index.php?id=1 from the list page#####
$anime = "SELECT * FROM anime WHERE id=$id";
$anime_query = mysql_query($anime) or die(mysql_error());
$thisanime = mysql_fetch_assoc($anime_query);
$amountepi = $thisanime['episodes'];
if(isset($_POST['epinum'])){
$epinum = $_POST['epinum'];  // Storing Selected Value In Variable
##############episodes number how many 1-2-3!!
$episodes = "SELECT * FROM episodes WHERE animeid = $id AND number = $epinum";
$episodes_query = mysql_query($episodes) or die(mysql_error());
$allepisodes = mysql_fetch_assoc($episodes_query);
}
?>
<html>
<!-- Header -->
<?PHP require('work/header.php'); ?>
<!-- Sidebar -->
<?PHP require('work/left.php'); ?>
</div><div></div><div></div></div><div></div></div></div>
<!-- bagian main -->
<div id='main-wrapper'>
<div><div><div><div><div></div><div><div></div></div></div><div></div></DIV><div></div><div>
<div class="post-container">
    <h3 class="post-title"><?PHP echo $thisanime['animename']; ?> <font style='float:right;'>Status:<font color='green'><?PHP echo $thisanime['status']; ?></h3>
    <div class="post-thumb"><img src="<?PHP echo $thisanime['imagecover']; ?>" /></div>
    <div class="post-content">
         <p></p>
        <font color="yellow">Year Of Release:<?PHP echo $thisanime['year']; ?></font>
        <p><font color="lightblue"><?PHP echo $thisanime['description']; ?> </p></font></div>
</div>


*******thisisthepartIwantonlytorefresh********


<tbody><tr><td>
<?PHP echo " <font size='4' color = 'blue'>Episode   " . $allepisodes["number"]. "        -->" . $allepisodes["name"]. "</font>"; ?>


<form class="anilist" action="" method="post">
<select class="listofepisodes" onchange='this.form.submit()' name="epinum" multiple='multiple'>
<?PHP if ($amountepi==3){ ?>
<option value='1' <?php if($allepisodes['number']==1) echo "selected='selected'"; ?>>Episode 1</option>
<option value='2' <?php if($allepisodes['number']==2) echo "selected='selected'"; ?>>Episode 2</option>
<option value='3' <?php if($allepisodes['number']==3) echo "selected='selected'"; ?>>Episode 3</option>
<?PHP }elseif ($amountepi==2){ ?>
<option value='1' <?php if($allepisodes['number']==1) echo "selected='selected'"; ?>>Episode 1</option>
<option value='2' <?php if($allepisodes['number']==2) echo "selected='selected'"; ?>>Episode 2</option>
<?PHP }elseif ($amountepi==1){ ?>
<option value='1' <?php if($allepisodes['number']==1) echo "selected='selected'"; ?>>Episode 1</option>
<?PHP } ?>
</select>
<noscript>&lt;input type="submit" value="Submit"&gt;</noscript>
</form>

 <iframe src="<?PHP echo $allepisodes['code']; ?>" width="408" height="324" frameborder="1" allowfullscreen></iframe>



*************till here************************



</div></div></div></div></div>
<!-- sidebar right -->
<?PHP require('work/right.php'); ?>
<!-- Footer -->
<?PHP require('work/footer.php'); ?>

1 个答案:

答案 0 :(得分:1)

如果您想发布表单并在iframe中显示结果,可以使用此功能。

<form target="refreshing_iframe">
 ...
</form>
<iframe name="refreshing_iframe" ... >

<强>来源 How do you post to an iframe?

修改

执行您想要做的事情的最佳方式是加载动画ID的所有剧集,以便最终获得每集的所有网址。然后,当有人选择不同的剧集时,您不需要再次联系服务器。您可以将iframe默认为第1集代码(网址)。然后只需为每个剧集添加链接,以便在点击时更新iframe src。