douhuan6065 2019-03-04 18:02
浏览 60

我想在搜索功能工作后显示当前搜索值

I am creating this for my varsity project. I am not so expert about it. so, I need someone to help me or guide me how to do it. Please see the image below: search page image at current situation on my web page

When i search with some value putting in input field it goes empty after search. But i want to show current search value after search results show as like as the image below: expected result on my webpage

The id's of the search fields are: application_number, document_number Can anyone suggest any URL where can i find this solution or write me code for me. I used php and mysql for show the search result. Here is the code if this helps you to understand:

 if(isset($_POST['searchbtn'])):

        $application_number = trim($_POST['application_number']);
        $document_number = trim($_POST['document_number']);


       $sql_search = "SELECT * FROM search_info LEFT JOIN country ON country.`country_id`=`search_info`.`country_id` WHERE search_info.`application_number` = '$application_number' AND search_info.`document_number` = '$document_number' AND search_info.`is_deleted`=0";

        $query = mysqli_query($con,$sql_search);
        $count = mysqli_num_rows($query);
        if($count>0):

       $search_result = mysqli_fetch_array($query);


 ?>

  <tr>
                <td><center><?=$search_result['bill_number']?></center></td>
                  <td><center><?=$search_result['application_number']?></center></td>
                  <td><center><?=$search_result['application_date']?></center></td>
                  <td><center><?=$search_result['document_number']?></center></td>
                  <td><center><?=$search_result['name']?></center></td>
                  <td ><center><?=$search_result['Country_Name']?></center></td>
                  <td><center><?=$search_result['type_pass']?></center></td>
                  <td><center><?=$search_result['time_frame']?></center></td>
                  <td><center><?=$search_result['acquisition_place']?></center></td>
                  <td style="color:<?=$search_result['color']?>"><center><?=$search_result['application_status']?></center></td>

        </tr>
        <?php else:?>
            <tr>
                <td colspan="10">No Record Found</td>
            </tr>
        <?php endif;?>

I think it can be done with jquery or ajax. But i don't know how to do it. My coding skill is beginner level, so please consider it. Thanks

  • 写回答

1条回答 默认 最新

  • dongzhang1987 2019-03-04 18:13
    关注

    I'm not sure if your project requires security enhancements, but if this should get the job done. It checks that the posted variable exists, if not it sets the variable to empty then it simply echoes that in the input.

    <?php
         $document_number = (isset($_POST["document_number"])) ? $_POST["document_number"] : "";
         $application_number = (isset($_POST["application_number"])) ? $_POST["application_number"] : "";
    ?>
    <input type="text" name="application_number" value="<?=$application_number?>">
    <input type="text" name="document_number" value="<?=$document_number?>">
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。