Jump to content

Expire Search Entries


anthonydamasco

Recommended Posts

As of right now my website has a "Job Search Feature" People looking for jobs can search, much like monster, or careerbuilder. Well in the back end I have small form for our staff to add jobs to the search

I can't seem to come up with a working script that will expire on days set by a form. For example if I say "this job expires 12/12/2006" it will remain searchable until that time.

Can anyone point me in the right direction?
Link to comment
https://forums.phpfreaks.com/topic/30248-expire-search-entries/
Share on other sites

[code]<form method="post" action="expiry1.php?staffid=<? echo $staffid ?>">
<table border="0">

<tr><td>Select job:</td><td><select name="a"><option value="">[Select One]
<?php

mysql_connect("localhost", $dbname, $dbpasswd )
    or die ("Unable to connect to server.");

mysql_select_db($database)
    or die ("Unable to select database.");

$result = mysql_query("SELECT * FROM `Job search` order by `whatever` ");

if ($myrow = mysql_fetch_array($result)) {

  do {

    printf("<option value=%d>
      %s", $myrow["jobid"], $myrow["jobname"]);

  } while ($myrow = mysql_fetch_array($result));

echo "</select>\n";

} else {

echo "Sorry, no records were found!";
}

?>
<font color="orange"> Mandatory field</font>
</td></tr>

<tr><td>Expiry date:</td><td><input type="text" name="b" size="20"></td>

</table>
<p>
<br><input type="submit" name="submit" value="Add"> </p>
</form>[/code]

then expiry1.php can be where the above gets processed ...

[code]<?php

$a = $_POST["a"];
$b = $_POST["b"];

if (!$a || !$b) die("Mandatory information not entered. Please use back button of browser.");

mysql_connect("localhost", $dbname, $dbpasswd )
    or die ("Unable to connect to server.");

mysql_select_db($database)
    or die ("Unable to select database.");

$sql = "INSERT INTO `Job search (jid, expdate) VALUES ('$a','$b') ";

$result = mysql_query($sql)
    or die (mysql_error());

echo "<b>Information entered</b>";

?>[/code]

And when you view you can define :
[code]<?
tdate = date(Y-m-d) ;

"Select * from job search where edate <= tdate " ; [/code]

so that would bring up only current jobs.

HTH
Link to comment
https://forums.phpfreaks.com/topic/30248-expire-search-entries/#findComment-139486
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.