0

这是在页面标题中搜索我的标题的第一种形式。

<form action="index.php?cat=search_results&learn_id=1" method="post">
      <div id="topSearchBodyStyle">
        <input type="text" name="search" class="topSearchTextBackground" />
      </div>
      <div id="topSearchButtonStyle">
        <input type="submit" name="submit" class="topSearchButtonBackground" value="" />
      </div>
    </form>

这是名为 searchPage.php 的页面

<?php 

    if (isset($_POST['search'])){ 
    $getSearch = clean_text($_POST['search']);
    $connectToDb = "select * from tutorials where tutorial_title like '%".$getSearch."%' and active=1"; 
    $searchResults = $db->query($connectToDb) or die($db->error);
    $numResultas = $searchResults ->num_rows;
        echo "<p class='counter_search'>Found : " . $numResultas . "</p>";
        switch ($numResultas) {

            case 0:
            include "searchPageAdvanced.php";
            break;

            case $numResultas >= 1:
            while($row = mysqli_fetch_array($searchResults)) {

            echo "<a class='counter_linkHeader' href='index.php?cat=tutorials_view&learn_id=5&tutorial_id=".$row['tutorial_id']."'>".$row['tutorial_title']."</a>";
            echo "<p class='counter_description'>";
            $your_desired_width=200;
            $description=$row['content'];
            if (strlen($description) > $your_desired_width) {$description = wordwrap($description, $your_desired_width); $description = substr($description, 0, strpos($description, "\n"))." ..."; } echo $description;
            echo"</p>";    
        }
            break;
            }

    }else{ 
    ?>
    <p>&nbsp;</p>
<table width="875" border="0">
  <tr>
    <td align="center" valign="middle"><img src="http://bytes.com/images/searchError.jpg" width="223" height="147" alt="search error" /></td>
  </tr>
  <tr>
    <td align="center" valign="middle">Sorry you came here by mistake <br />
      please use the search box to get results</td>
  </tr>
</table>
<p>&nbsp;</p>
    <?php
    }
?>

是高级搜索页面。这将搜索内容。

<form action="" method="post">

        <input type='text' name='searchAdv' />

        <input type='submit' name='submit_adv' value='Search' id="submit_adv" />
    </form>
    </td>
  </tr>
  <tr>
    <td align='center' valign='middle'><p>Sorry you came here because your search didn't </p>
      <p>meet any of the content try advanced!!</p></td>
  </tr>
</table>

<?php
    if (isset($_POST['submit_adv'])){
    $getSearch = clean_text($_POST['searchAdv']);

    $connectToDb = "select * from tutorials where content like '%".$getSearch."%' and active=1"; 
    $searchResultsAdv = $db->query($connectToDb) or die($db->error);

    while($rowAdv = mysqli_fetch_array($searchResultsAdv)) {

            echo "<a class='counter_linkHeader' href='index.php?cat=tutorials_view&learn_id=5&tutorial_id=".$rowAdv['tutorial_id']."'>".$rowAdv['tutorial_title']."</a>";
            echo "<p class='counter_description'>";
            $your_desired_width=200;
            $description=$rowAdv['content'];
            if (strlen($description) > $your_desired_width) {$description = wordwrap($description, $your_desired_width); $description = substr($description, 0, strpos($description, "\n"))." ..."; } echo $description;
            echo"</p>";    
        }
    }
  ?> 

现在问题再次出现在高级搜索页面,搜索页面工作正常

但是当我在高级页面中搜索时,它返回的页面是空的,就像他没有为输入区域拿任何东西一样SearchAdv

4

0 回答 0