我有一个职位网站,我希望当用户发布职位时,该职位在网站管理面板获得批准之前不应显示。
这是我显示职位的主页:
<?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表结构
最佳答案
向表中添加一个名为“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
关于php - mysql如何隐藏一条记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23647775/