PHP下拉动态页面填充
是否可以使用纯PHP从下拉菜单中选择不同的PHP下拉动态页面填充,php,drop-down-menu,Php,Drop Down Menu,是否可以使用纯PHP从下拉菜单中选择不同的include_once'template.PHP' 在我看来,应该是这样的: <?php Connections to db Include libs etc Include header.php ?> <Form to select which include template.php to display> <?php Include dynamictemplate.php <- from form d
include_once'template.PHP'
在我看来,应该是这样的:
<?php
Connections to db
Include libs etc
Include header.php
?>
<Form to select which include template.php to display>
<?php
Include dynamictemplate.php <- from form dropdown on select.
Include footer
?>
或者我最好使用AJAX或JS来实现这一点?是的,AJAX可以非常高效地完成这一工作。无论你是想打开整个页面还是某些部分,都可以通过AJAX以非常轻松的方式处理。如果有任何具体问题,请返回。(这是我最喜欢的主题,或者更好的是,标记我)我在PHP中找到了一种方法
<form name="form1" method="POST" action="manage.php">
<select name="select" onChange="document.form1.submit()">
<option selected>Select a Table</option>
<option value="product">Product</option>
<option value="series">Series</option>
<option value="set">set<option>
</select>
</form>
<?php
if (isset($_POST['select']) && $_POST['select']) { } else { include
manage_product.php'; }
if (isset($_POST['select']) && $_POST['select'])
{
if ($_POST['select'] == 'product')
include 'manage_product.php';
if ($_POST['select'] == 'series')
include 'manage_series.php';
if ($_POST['select'] == 'set')
include 'manage_set.php';
} else {
return;
}
?>
选择一个表
产品
系列
设置
您想通过调用select
input change上的不同php文件异步更改页面的一部分,这就是您想要的吗?是的,我现在没有很多子网站来查看单独php文件中的表数据。F.ex现在我有manage.php站点,带有指向users.php、category.php、products.php、series.php、set的按钮链接.php。我希望包含manage.php中的所有内容