如何在mysql中隐藏记录

时间:2014-05-14 07:05:59

标签: php mysql

我有一个工作网站,我希望当用户发布工作时,在网站管理员面板上批准之前不应该显示该工作。

这是显示工作的主页:

<?php
$result = mysqli_query($conn,"SELECT * FROM job ORDER BY `CreatedTime` DESC");

echo "<table border='0' cellpadding='0' cellspacing='0' class='table-fill'>
<tr>
<th width='300px' position='fixed' overflow='hidden'>Job Title</th> 
<th width='100px'>Company Name</th>
<th width='100px'>Location</th>
<th width='80px'>Closing Date</th>
</tr>";

while($row = mysqli_fetch_array($result) ) {
  echo "<tr>";
  echo "<td><a href='job.details.php?id=".$row['id']."' class='positiontitle-link'>" . $row['positiontitle'] . "</td>";
  echo "<td>" . $row['companyname'] . "</td>";
  echo "<td>" . $row['location'] . "</td>";
  echo "<td>" . $row['closingdate'] . "</td>";
  echo "</tr>";

}

echo "</table>";

这是我通过以下方式发布职位的表格:

<div class="body">
        <form action="insert.php" method="post" class="ara-form">
                <header>Enter Job Details</header>

                <fieldset>                  
                    <div class="row">
                        <section class="col col-6">
                            <label class="input">
                            <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Job Title" name="positiontitle">
                                <span class="error"></span>
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Organization / Company Name" name="companyname">
                            </label>
                        </section>
                    </div>

                    <div class="row">
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Location" name="location" >
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Job Category  e.g. IT" name="jobcategory">
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Employment Type  e.g. Full Time" name="employmenttype">
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Salary  e.g. 5000$" name="salary">
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Duration  e.g. Permanent" name="duration">
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i> 
                                <input type="text" placeholder="Timing  e.g. 8 AM - 4 PM" name="timing">
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Nationality" name="nationality">
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Number of Vacancy  e.g. 2 Post(s)" name="numberofvacancy">
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Experience  e.g. 3 Years" name="experience">
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Closing Date" id="datepicker" name="closingdate">
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Gender" name="gender">
                            </label>
                        </section>
                        <section class="col col-6">
                            <label class="input">
                                <i class="icon-append icon-company"></i>
                                <input type="text" placeholder="Education  e.g. Bachelor" name="education">
                            </label>
                        </section>
                     </div>             
                </fieldset>

                <fieldset>  

                    <section>
                        <label class="textarea">

                            Tell us about your company background
                            <textarea id="editor1" rows="10" cols="80"  name="background" placeholder="Tell us about your company background"></textarea>
                        </label>
                    </section>                  
                    <section>
                        <label class="textarea">

                            Job Summary
                            <textarea id="editor2" rows="10" cols="80"  name="summary" placeholder="Job Summary"></textarea>
                        </label>
                    </section>
                    <section>
                        <label class="textarea">

                            Job Duties and Responsibilities
                            <textarea id="editor3" rows="10" cols="80"  name="duty"  placeholder="Job Duties and Responsibilities"></textarea>
                        </label>
                    </section>
                    <section>
                        <label class="textarea">

                            Qualification Needed
                            <textarea id="editor4" rows="10" cols="80"  name="qualification"  placeholder="Qualification Needed"></textarea>
                        </label>
                    </section>  
                    <section>
                        <label class="textarea">

                            Skills Needed
                            <textarea id="editor5" rows="10" cols="80"   name="skill" placeholder="Skills Needed"></textarea>
                        </label>
                    </section>  
                    <section>
                        <label class="textarea">

                            Submission Guideline
                            <textarea id="editor6" rows="10" cols="80"   name="submission" placeholder="Submission Guideline"></textarea>
                        </label>
                    </section>  
                                        <section>
                        <label class="textarea">

                            Words for making search easy e.g IT | Officer | Manager | ...
                            <textarea id="editor7" rows="10" cols="80"   name="search" placeholder="Words for making search easy e.g IT | Officer | Manager | ... "></textarea>
                        </label>
                    </section>  
                </fieldset>
                <footer>
                    <p>Fill all fields to activate the submit button.</br>
                    Thanks</p><i class="fa fa-check" style="float: right; position: relative; right: 22px; color: white; z-index: 1; padding-top: 23px;"></i><input class="button" type="submit" id="exinput" value="Submit"/>

                   <div style="float: right; padding-right: 10px;"><?php
                   include "../module/back.php";
                   ?></div>
                    </footer>
            </form>

        </div>

这是显示工作详情的页面:

<div style="width:900px;">
    <div style="float:left; width:200px;"class="ara-form"><header style="font-size:12px; color:#666666; font:Arial, sans-serif; padding:7px;"><?php
   $result = mysqli_query($conn,"SELECT * FROM job WHERE id = '".$_GET['id']."' ORDER BY `CreatedTime` DESC");

   $jobdetails = mysqli_fetch_assoc($result);

    echo '<strong>Job Title</strong></br> '.$jobdetails['positiontitle'].'<hr class="job">';
    echo '<strong>Company Name</strong></br> '.$jobdetails['companyname'].'<hr class="job">';
    echo '<strong>Location</strong></br> '.$jobdetails['location'].'<hr class="job">';
    echo '<strong>Closing Date</strong></br> '.$jobdetails['closingdate'].'<hr class="job">';
    echo '<strong>Number of Vacancy</strong></br> '.$jobdetails['numberofvacancy'].'<hr class="job">';
    echo '<strong>Job Category</strong></br> '.$jobdetails['jobcategory'].'<hr class="job">';
    echo '<strong>Duration</strong></br> '.$jobdetails['duration'].'<hr class="job">';
    echo '<strong>Employment Type</strong></br> '.$jobdetails['employmenttype'].'<hr class="job">';
    echo '<strong>Salary</strong></br> '.$jobdetails['salary'].'<hr class="job">';
    echo '<strong>Timing</strong></br> '.$jobdetails['timing'].'<hr class="job">';
    echo '<strong>Nationality</strong></br> '.$jobdetails['nationality'].'<hr class="job">';
    echo '<strong>Gender</strong></br> '.$jobdetails['gender'].'<hr class="job">';
    echo '<strong>Experience</strong></br> '.$jobdetails['experience'].'<hr class="job">';
    echo '<strong>Education</strong></br> '.$jobdetails['education'].'<hr class="job">';
    echo '<strong>Gender</strong></br> '.$jobdetails['gender'].'<hr class="job">';
    echo '<strong>Gender</strong></br> '.$jobdetails['gender'].'<hr class="job">';
?></header>


</div>
    <div style="float:left; width:600px;" class="ara-form">
    <fieldset style="font-size:12px; color:#666666; font:Arial, sans-serif;">


    <div style="width:100px; float:right; padding-left:2px;"><?php
    include "../module/back.php";?>

    <button class="button" style="margin-right: -20px; width: 120px; padding-left: 10px;" value="Go Back"><i class="fa fa-check-circle" style="float: right; position: absolute; right: 6px; color:             white; z-index: 1; padding-top: 31px; margin-top: -20px;"></i><?php
    $query  = "select id from jobviews where job_id=".$job_id."";
    $result = mysqli_query($conn, $query);
    echo "Views  ".mysqli_num_rows($result);?></button>


    <?php
    include "../module/back.php";?>
    <?php
    include "../module/back.php";?>
    </div>



    <?php
    echo '<p><strong id="ara-form">Company Background</strong></br> '.$jobdetails['background'].'</p></br>';
    echo '<p><strong id="ara-form">Job Summary</strong></br> '.$jobdetails['summary'].'</p></br>';
    echo '<p><strong id="ara-form">Job Duties and Responsibilities</strong></br> '.$jobdetails['duty'].'</p></br>';
    echo '<p><strong id="ara-form">Qualification</strong></br> '.$jobdetails['qualification'].'</p></br>';
    echo '<p><strong id="ara-form">Skills</strong></br> '.$jobdetails['skill'].'<hr class="job"></p></br>';
    echo '<p><strong id="ara-form">Submission Guideline</strong></br> '.$jobdetails['submission'].'</p></br>';
    echo '<p><strong id="ara-form">Words to search this job</strong></br> '.$jobdetails['search'].'</p></br>';
    ?>
    </fieldset></div>

    <div style="float:left; width:33.4%; background:#ccc;">three</div>
    <div style="clear:both;"></div>
</div>

</div>

这是我的MySQL表格结构

structure

2 个答案:

答案 0 :(得分:0)

在表格中添加一个名为approved int 1

的字段

在您的第一个代码块更改中:

$result = mysqli_query($conn,"SELECT * FROM job ORDER BY `CreatedTime` DESC");

$result = mysqli_query($conn,"SELECT * FROM job WHERE approved=1 ORDER BY `CreatedTime` DESC");

并在第三个代码块中更改:

$result = mysqli_query($conn,"SELECT * FROM job WHERE id = '".$_GET['id']."' ORDER BY `CreatedTime` DESC");

$result = mysqli_query($conn,"SELECT * FROM job WHERE approved=1 AND id = '".$_GET['id']."' ORDER BY `CreatedTime` DESC");

您还需要添加一些代码来批准新提交的内容,以便将批准的内容从0更改为1

答案 1 :(得分:0)

在表格中添加一个列,用于确定帖子是否已经过验证并且默认为false

ALTER TABLE `job`  ADD COLUMN `approved` BOOL NOT NULL DEFAULT '0';

然后当你确认工作岗位没问题时

Update job set approved=1 where id='<the_job_post_id>';

当您将查询仅查看已批准的

SELECT * FROM job where approved=1 ORDER BY `CreatedTime` DESC;