Jump to content

Need to know how to set ad listings to expire 30 days in php mysql? PHP


Recommended Posts

I need to know how to set ad listings to expire 30 days in php mysql?
i know i have to ad some kind of feids in the myql table of listings

here is my php code to the page where it displays the for sale listings and catagories

</> <div class="orageBGfg" style="padding:2px 0px 2px 20px;">
<b>Category</b> : <? echo "$category";?> 
<?
$query = "SELECT COUNT(*) FROM forsale_content WHERE category='$category' AND status='online'"; 
$numentries = mysql_query($query) or die("Select Failed!");
$numentry = mysql_fetch_array($numentries); 
?>
</div>

  <b class="orageBG">
  <b class="orageBG5"></b>
  <b class="orageBG4"></b>
  <b class="orageBG3"></b>
  <b class="orageBG2"><b></b></b>
  <b class="orageBG1"><b></b></b></b>
</div>

<div id="title1">
Click on title to view description
</div>


<? 
$sql = "SELECT * FROM forsale_content WHERE category='$category' AND status='online' ORDER BY id DESC"; 
$result = mysql_query($sql); 
while ($record = mysql_fetch_object($result)) { 

$question = nl2br($record->description);
$answer = nl2br($record->answer);
?>

<div id="list">
<a href="?q=detail&id=<? echo"$record->id";?>"><? echo "$record->title"; ?><?php if($record->price != "") { ?>
               - $<? echo number_format($record->price);?>
<?php } ?></a> 
 <span>(<? echo "$record->city"; ?>) (<? echo "$record->postdate";?>)</span>

</div>

<?
}
?></>

here is the mysql table for the listing content

</>CREATE TABLE IF NOT EXISTS `forsale_content` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `postdate` date DEFAULT NULL,
  `posttime` varchar(10) DEFAULT NULL,
  `name` varchar(250) DEFAULT NULL,
  `phone` varchar(250) DEFAULT NULL,
  `address` varchar(250) DEFAULT NULL,
  `city` varchar(255) DEFAULT NULL,
  `country` varchar(250) DEFAULT NULL,
  `email` varchar(250) DEFAULT NULL,
  `website` varchar(250) DEFAULT NULL,
  `title` varchar(250) DEFAULT NULL,
  `price` varchar(250) DEFAULT NULL,
  `description` text,
  `category` varchar(250) DEFAULT NULL,
  `photo` varchar(250) DEFAULT NULL,
  `status` varchar(250) DEFAULT NULL,
  `password` varchar(25) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=46 ;</>

any help how to make this script s listing exprie after 30 or 60 or 90 days would be great thanks sorry for the bad code had to updat some of it to work with php 5.3 and up

Store an expiration date and only show ads that haven't expired yet. For existing ads you can update the table using

UPDATE forsale_content SET thenameofthenewcolumn = postdate + INTERVAL ?? DAY
Obviously change thenameofthenewcolumn and ?? as needed.

 

It's definitely possible to not add the column and enforce 30/60/90 days on all ads - easily, in fact - but using the column gives you more flexibility.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.