2015-12-20 125 views
0

我已经创建了一个搜索页面,并且遇到了一些问题。只显示相关搜索结果

数据显示在页面上,但我也使用表单中的某些字段作为特定字段,所以当我在这些字段中输入数据并点击搜索时,它会在显示页面的顶部显示搜索字段与其余的数据,但我只需要属于我的搜索的数据。

CODE:

<?php 
    include('connect.php'); 
?> 


<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<?php include('include/head.php')?> 
</head> 
<body> 
<div id="header-wrapper"> 
    <div id="header"> 
     <div id="menu"> 
      <ul> 
       <?php include('include/menu.php') ?> 
       <a href="logout.php">Logout</a> 
      </ul> 
     </div> 

    </div> 
</div> 

<div id="logo"> 
    <?php include('include/logo.php'); ?> 
</div> 
<div id="wrapper"> 
    <div id="page"> 

     <div id="page-bgtop"> 


      <div id="content"> 
      <div class="post"> 
        <div class="entry-image"> 
        <?php 
        $q=mysql_query("SELECT count(php) AS ph, count(dotnet) AS dot, count(design) AS des FROM candidate"); 
        while($row=mysql_fetch_array($q)) 
        { 
        ?> 
        <form name="" method="post"> 
        <table border="1" cellpadding="10" cellspacing="1" width="280" height="200"> 
        <th colspan="5" bgcolor="orange" >Total Number of Resume by skills</th> 
        <tr> 

        <th><B>PHP</B></th> 
        <th><B>DOTNET</B></th> 
        <th><B>DESIGN</B></th> 
        </tr> 

        <td><?php echo "$row[ph]"; ?></td> 
        <td><?php echo "$row[dot]"; ?></td> 
        <td><?php echo "$row[des]"; ?></td> 
        </table> 
        </form> 
        <?php 
        } 
        ?> 
        </div> 

        <h2 class="title">Welcome to Resume </h2> 



        <div class="entry"> 
         <p> 
         <form name="search" method="post" action="searchview.php"> 
         <table> 
         <tr> 
         Id: <input type="text" name="id" /></br></br> 
         Name:<input type="text" name="name" /><br/></br> 
         Expected Salary:<input type="text" name="es" /><br/></br> 
         Skill Rate: <input type="text" name="sr" /><br/> </br> 
         Salary:<input type="text" name="cs" /></br></br> 
         <input type="submit" name="submit" value="seach" /><input type="reset" name="reset" value="reset" /> 
         </tr> 
         </table> 
         </form> 
         </p> 
        </div> 
       </div> 
       <div class="post" > 
       <?php 
       $query=mysql_query("select * from candidate"); 
       while($row=mysql_fetch_array($query)) 
       { 
       $sno=$row['id']; 
       $image=$row['image']; 
       $name=$row['fname']; 
       $es=$row['es']; 
       $sr=$row['sr']; 
       $cs=$row['cs']; 
       ?> 
       <form name="view" method="post" action="searchview.php" > 
       <table border="1" cellpadding="30" class="centered" width="20" > 
       <tr> 
       <th width="150">S.NO</th> 
       <th width="150">IMAGE</th> 
       <th width="150">NAME</th> 
       <th width="150">EXPECTED SALARY</th> 
       <th width="150">SKILL RATE</th> 
       <th width="150">SALARY</th> 
       <th width="150">ACTION</th> 
       </tr> 

       <td><?php echo "$row[id]"; ?></td> 
       <td><div class="rightdiv1a"><img src="<?php echo 'img/'.$row['image']; ?>" style="height:120px; width:145px; "></div></td> 
       <td><?php echo "$row[fname]"; ?></td> 
       <td><?php echo "$row[es]"; ?></td> 
       <td><?php echo "$row[sr]"; ?></td> 
       <td><?php echo "$row[cs]"; ?></td> 
       <td><a href="view.php?id=<?php echo "$row[id]"; ?>"><img alt='view' title='view' src='images/view.png' width='15px' height='15px' hspace='20' /></a></td> 
       <td><a href="edit.php?id=<?php echo "$row[id]"; ?>"><img alt='Edit' title='Edit' src='images/edit.png' width='15px' height='15px' hspace='20' /></a></td> 
       <td><a onclick="return confirm('Would you like to delete?');" href="delete.php?id=<?php echo "$row[id]"; ?>"><img alt='delete' title='delete' src='images/delete.png' width='15px' height='15px' hspace='20' /></a></td> 
       </table> 
       </form> 
       <?php 
       }?> 
       </div> 
      </div> 

     </div> 
    </div> 
</div> 

<div id="footer-bgcontent"> 
    <div id="footer"> 
      <?php// include('include/footer.php');?>  
    </div> 
</div> 

</body> 
</html> 
<?php// } ?> 

此代码现在显示的数据,但我想对数据进行筛选,并只显示属于我的搜索结果,并有其余的消失。

这里是我的形式一些截图:

search field of the fomr

And in this table my filter data must displayed here n rest of the data must disappear

请帮助, 在此先感谢..

+0

您好感谢您的回答,我真正想要的是,要显示后的搜索表单搜索进程的另一个搜索,但在结果表中,我只想过滤搜索结果,例如当用户访问搜索页时,它以表格形式显示整个数据,并且还有一些搜索字段,所以当用户填写搜索字段时,搜索按钮,我只想在表格中的字段相关的答案,旧的数据必须从那里删除,外汇,如果我在字段史蒂夫输入一个名称,所以系统必须代表该字段带来搜索结果..必须检查屏幕截图 – Anuj

回答

0

如果我理解正确的问题,你想显示搜索结果,但不再显示搜索表单。如果是这种情况,然后将你的第二个“后”的div顶部和在如果把它包:

if (!empty($_POST)) { 
    // Process POST results here: 
    ... 
    die(); // end processing so the form doesn't display again 
}