如何使用html5,css3和php创建交互式搜索栏,结果构建并返回一个新的组合页面?

问题描述 投票:-1回答:1

我需要在导航栏下方顶部的网页上嵌入一个交互式搜索标题。它需要像这样:

hand drawn prototype concept sketch for interactive search bar

我的代码位于下方,我是一个TOTAL编码新手..

这是一个我甚至不知道要搜索什么的情况?!如果它应该是HTML或PHP或一些卷积。

将不胜感激,

谢谢!

.......

这是我发现的,但它不适用于解决问题或我需要的语言:

Change href link with php form

Interactive javascript charting library to display bar graphs on a timeline

how to create search bar dropdown in angular 4?

how to create a live search bar?

Creating an Interactive Multi Field Search Bar in MS-ACCESS

How do I create an interactive selection?

    <!DOCTYPE html>
    <html>
    <body>

    <h1>BlueBubble.Tech</h1>

    <?php

    /* interactive search sentence below header*/

    function SearchSentence() {

    global $name, $clienttype, $product;

    $name = "Phoenix";
    $clienttype = " solopreneur";
    $product = " a domain";

    echo "<p>Hello $name, which problem can we help you with today? </p>";
    echo "<p>I am a: $clienttype </p>";
    echo "<p>looking for: $product </p>";
     }
    SearchSentence()



    /*Name: <input type="text" name="name"><br>
    E-mail: <input type="text" name="email"><br>
    <input type="submit">
     </form>

     }
     ?>
     */

     ?>

     </body>
     </html> 
php html5 full-text-search searchbar
1个回答
0
投票

你的问题很广泛,但也许这会帮助你开始。

在index.php的第一次运行时,页面顶部的php部分不会被执行,底部会显示html表单。

当您点击表单提交按钮(Go)时,表单数据将再次提交到同一页面,并且顶部的php部分现在已执行。

然后php部分读取表单提交的值,然后您可以使用它们来确定要显示的页面。

要决定显示哪个页面,我使用的是if/else if语句。根据提交的值,然后显示include()中的一个html页面。

在这个例子中,我只添加了新手+域和新手+品牌组合的子句,所以你必须为此添加更多内容。

我试图让这个例子尽可能简单,希望它能让你知道如何完成这样的事情。也许你可以首先尝试理解这段代码是如何工作的(google你不理解的部分或者其他东西),然后从那里构建。 :)

的index.php

<?php
// If the form below was submitted
if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    // Collect the submitted information 
    $name = $_POST['name'];
    $clienttype = $_POST['clienttype'];
    $product = $_POST['product'];

    echo "<p>Hello $name, which problem can we help you with today? </p>";
    echo "<p>I am a: $clienttype </p>";
    echo "<p>looking for: $product </p>";

    // if newbie and domain were selected..
    if ($clienttype == 'newbie' && $product == 'domain') {

        // display the page for newbie + domain
        include('newbie_domain.html'); 

    // if newbie and branding were seleted..
    } else if ($clienttype == 'newbie' && $product == 'branding') {

        // display the page for newbie + branding
        include('newbie_branding.html'); 

    } // And so on for the other combinations

    // Do not display the form again
    exit();
}
?>
<!DOCTYPE html>
<body>
<h1>BlueBubble.Tech</h1>

<form method="post">
<label for="name">My name is</label>
<input type="text" name="name" id="name" required>

<label for="clienttype">I am a</label>
<select name="clienttype" id="clienttype" required>
<option value="newbie">newbie</option>
<option value="professional">professional</option>
<option value="solopreneur">solopreneur</option>
<option value="business">business</option>
</select>

<label for="product">looking for a</label>
<select name="product" id="product" required>
<option value="domain">domain</option>
<option value="branding">branding</option>
<option value="website">website</option>
<option value="app">app</option>
<option value="uxdesign">uxdesign</option>
</select>

<input type="submit" value="Go >">
</form>
</body>
</html>

newbie_domain.html

<!DOCTYPE html>
<body>
<h1>BlueBubble.Tech</h1>
<p>This is the page for newbie & domain!</p>
</body>
</html>

newbie_branding.html

<!DOCTYPE html>
<body>
<h1>BlueBubble.Tech</h1>
<p>This is the page for newbie & branding!</p>
</body>
</html>
© www.soinside.com 2019 - 2024. All rights reserved.