Jump to content

Recommended Posts

Hello, I got a problem here and I need to solve this as swiftly as I can.

 

The problem is, my script is supposed to be designed to erase (expire) listing posts on my classified ads after 2 days for a free ad listing.

 

This is not an automated thing, it is more of an action-based-event. The listing only gets deleted off of the classified ad when a user logs into their account and clicks on managelisting.php. I want the listings to be deleted off the ads list automatically. It seems to be an action-based-event as stated earlier. Does anyone got an idea how to make it this way?

 

Here is the php script for managelisting.php

 

<? 	include("mail.php"); ?>
<script>
   function delarea(del_id)
{
if(confirm("Delete this Ad?"))
   {
   window.location.href="deletelisting.php?id="+del_id;
   }
return false;
}
</script>
<h1 class="infoHead">Manage Listing</h1>
<p>Free Listings </p>
<table width="570" cellspacing="0" cellpadding="0" class="manageListing">
  <tr class="manageListing">
    <td width="17%" align="center">Ad title </td>
    <td width="18%" align="center">Expiration date </td>
    <td width="17%" align="center">SubCat</td>
    <td width="15%" align="center">Status</td>
    <td width="17%" align="center">Control</td>
    <td width="16%" colspan="2" align="center">Action</td>
  </tr>
</table>
      <? while($line= mysql_fetch_array($r1)) {

  if($line[status] != 'expired') {
  
  
  
?>

<table width="570" cellspacing="0" cellpadding="0" class="manageListing">
  <tr class="manageListing">

    <td width="17%" align="center" class="manageListing"><? if(strlen ($line[CompanyName]) > 10) { $text = substr($line[CompanyName],0,; echo stripslashes($text); echo " ..."; }else { echo stripslashes($line[CompanyName]); }   ?></td>
    <td width="18%" align="center" class="manageListing"><?=$line[expd]?>
      <? 
  list($year , $month , $day) = explode("-" ,$line[expd]);

date('Y-m-d' , mktime(0,0,0,date(m) , date(d), date(Y)));
$q2 = "select * from yellow_agents where AgentID = '$_SESSION[AgentID]'";
$m2 = mysql_query($q2);
$mf = mysql_fetch_array($m2);
   if($month <= date(m) && $day <= date(d) && $line[expd] != 'Pending' && $line[expd] != '0' && $line[expd] != 'Never') 
{

$q1 = "update yellow_posts set status = 'expired' where CompanyName = '$line[CompanyName]';";
$m1 = mysql_query($q1);


Mailer($mf[email],expired,$line[PostID]);
}


$settings = "select * from yellow_settings";
$mysqlsettings = mysql_query($settings);
$fetch2 = mysql_fetch_array($mysqlsettings);

$expiration = $day - $fetch2[exp_notice];


if($expiration == date(d)) {
Mailer($mf[email],exp_notice,$line[PostID]);

}


?></td>
    <td width="17%" align="center" class="manageListing">

<?

 $qr = "select * from yellow_subcat where subcatid = '$line[subCategoryID]';"; 
 $msq = mysql_query($qr);
 $a = mysql_fetch_array($msq);


     if( $a[O1] != '0' ||
	     $a[O2] != '0' ||
	     $a[O3] != '0') { $color = "background-color:#CFD9E2;";
        }
	 else {

	 $color = "background-color:#FFFFFF;";

  }



 echo "<p  style=\"$color\">".stripslashes($a[subcatname])."</p>";

?>	</td>
    <td width="15%" align="center" class="manageListing">
<? 
if($line[status] == 'notconf') {

$query = "update yellow_posts set expd = 'Pending' where PostID = '$line[PostID]'";
mysql_query($query);


 echo " <img src=\"images/notconf.gif\" border=\"0\" /> "; }

if($line[status] == 'notpaid') { 

$query = "update yellow_posts set expd = 'Pending' where PostID = '$line[PostID]'";
mysql_query($query);

echo " <a href=\"paid_lists.php?subcat=".$line[subCategoryID]."&id=".$line[PostID]."\" style=\"color:#FF3300;\"><img src=\"images/notpaid.gif\" border=\"0\" /></a> "; 
} 
else { 

if($line[status] == 'active') { echo " <img src=\"images/active.gif\" border=\"0\" /> "; }

}

?></td>
    <td width="17%" align="center" class="manageListing"><? 

$q2 = "select * from yellow_subcat where subcatid = '$line[subCategoryID]'";
$mysql2 = mysql_query($q2);
$fetch2 = mysql_fetch_array($mysql2);

if(($line[status] == 'active' or $line[status] == 'notpaid') and ($fetch2[OF1] != '0' or $fetch2[OF2] != '0' or $fetch2[OF3] != '0')) {	
?><a href="make_featured.php?id=<?=$line[PostID]?>&subcat=<?=$line[subCategoryID]?>" style="color:#0099FF;"><img src="images/feature.gif" border="0" /></a><? }else { echo ""; } ?>	</td>
    <td width="5%" class="manageListing"><div align="center"><a href="editlisting.php?id=<?=$line[PostID]?>">Edit</a></div></td>
    <td width="11%" class="manageListing"><div align="center"><a href="deletelisting.php?id=<?=$line[PostID]?>">Delete</a></div></td>
  </tr>
</table>
  	    <?  }}?>
<? if ($aset[mem_allow] == 'yes') {
?>
<p>Featured Listings </p>
<table width="570" border="0" cellspacing="0" cellpadding="0" class="manageListing">
  <tr class="manageListing">
    <td width="17%" align="center">Ad title </td>
    <td width="18%" align="center">Expiration date </td>
    <td width="17%" align="center">SubCat</td>
    <td width="15%" align="center">Status</td>
    <td width="17%" align="center">Control</td>
    <td width="16%" colspan="2" align="center">Action</td>
  </tr>
</table>
      <? while($line= mysql_fetch_array($r2))
{


if(count(mysql_num_rows($r2)) > 0) {
?>
<table width="570" border="0" cellspacing="0" cellpadding="0" class="manageListing">
  <tr class="manageListing">
    <td width="17%" align="center" class="manageListing"><? if(strlen ($line[CompanyName]) > 10) { $text = substr($line[CompanyName],0,; echo stripslashes($text); echo " ..."; }else { echo stripslashes($line[CompanyName]); }   ?></td>
    <td width="18%" align="center" class="manageListing"><?=$line[expd]?>
<? 
list($year , $month , $day) = explode("-" ,$line[expd]);

date('Y-m-d' , mktime(0,0,0,date(m) , date(d), date(Y)));

   $qr = "select * from yellow_subcat where subcatid = '$line[subCategoryID]'";
   $ms = mysql_query($qr);
   $ft = mysql_fetch_array($ms);

   if($month <= date(m) && $day <= date(d) && $line[expd] != 'Pending' && $line[expd] != '0' && $line[expd] != 'Never') 
{

  if ($ft[O1] != '0' || $ft[O2] != '0' || $ft[O3] != '0') {
  
  $status = 'notpaid';
  $expd = 'Pending';
  
  }
  elseif($ft[O1] == '0' && $ft[O2] == '0' && $ft[O3] == '0') {
  $status = 'active';
}


$q1 = "update yellow_posts set status = 'expired' , expd = '$expd' where CompanyName = '$line[CompanyName]';";
$m1 = mysql_query($q1);
	$q2 = "select * from yellow_agents where AgentID = '$_SESSION[AgentID]'";
$m2 = mysql_query($q2);
$mf = mysql_fetch_array($m2);
Mailer($mf[email],expired,$line[PostID]);
}
	$settings = "select * from yellow_settings";
$mysqlsettings = mysql_query($settings);
$fetch2 = mysql_fetch_array($mysqlsettings);

$expiration = $day - $fetch2[exp_notice];


if($expiration == date(d)) {
Mailer($mf[email],exp_notice,$line[PostID]);

}
?>	</td>
    <td width="17%" align="center" class="manageListing"><?

 $qr = "select * from yellow_subcat where subcatid = '$line[subCategoryID]';"; 
 $msq = mysql_query($qr);
 $a = mysql_fetch_array($msq);


     if( $a[O1] != '0' ||
	     $a[O2] != '0' ||
	     $a[O3] != '0') { $color = "background-color:#CFD9E2;";
        }
	 else {

	 $color = "background-color:#FFFFFF;";

  }



 echo "<p  style=\"$color\">".stripslashes($a[subcatname])."</p>";

?></td>
    <td width="15%" align="center" class="manageListing"><? if($line[status] == 'featured') { echo "<img src=\"images/featured.gif\" border=\"0\" />"; }?></td>
    <td width="17%" align="center" class="manageListing"><a href="make_featured.php?id=<?=$line[PostID]?>&subcat=<?=$line[subCategoryID]?>" style="color:#0099FF;"><?php if ($line[expd]!='Never'){ ?> <img src="images/extend.gif" border="0" /><?php ;} ?></a></td>
    <td width="4%" class="manageListing"><div align="center"><a href="editlisting.php?id=<?=$line[PostID]?>">Edit</a></div></td>
    <td width="12%" class="manageListing"><div align="center"><a href="#" onclick="return delarea('<?=$line[PostID]?>')">Delete</a></div></td>
  </tr>
</table>
<p><? } }  }?>
</p>
    <p>Expired Listings </p>
    <table width="570" border="0" cellspacing="0" cellpadding="0" class="manageListing">
          <tr class="manageListing">
            <td width="22%" align="center">Ad title </td>
            <td width="23%" align="center">Control</td>
          </tr>
</table>
	      <? while($line= mysql_fetch_array($r3))
{


if(count(mysql_num_rows($r3)) > 0) {
?>
        <table width="570" border="0" cellspacing="0" cellpadding="0" class="manageListing">
          <tr>
            <td width="17%" align="center" class="manageListing"><?=stripslashes($line[CompanyName])?></td>
            <td width="18%" align="center" class="manageListing"><a href="managelisting.php?renew=1&subcatid=<?=$line[subCategoryID]?>&PostID=<?=$line[PostID]?>"><img src="images/renew.gif" border="0" /></a></td>
          </tr>
</table>


<?

if($_GET[renew] == '1') {

$settings = "select * from yellow_settings";
$mysqlsettings = mysql_query($settings);
$fetch2 = mysql_fetch_array($mysqlsettings);


$query = "select * from yellow_subcat where subcatid = '$_GET[subcatid]'";
$mysql = mysql_query($query);
$fetch = mysql_fetch_array($mysql);

if($fetch[O1] != '0' || $fetch[O2] != '0' || $fetch[O3] != '0') {
   
   $status = "notpaid";
   $expd = "Pending";
   
   }

elseif($fetch[O1] == '0' && $fetch[O2] == '0' && $fetch[O3] == '0') {

if($fetch2[approve_free] == 'yese') {

$status = "active";
if ($fetch2[freelex]=='0') { $expd='Never'; } else
$expd = date('Y-m-d' , mktime(0,0,0,date(m) , date(d) + $fetch2[freelex], date(Y)));
} 

else {

$status = "notconf";
$expd = "Pending";
   
    }

}

$update = "update yellow_posts set status = '$status' , expd = '$expd' where PostID = '$_GET[PostID]'";
$mysql2 = mysql_query($update);

}





?>		<? }} 


if (!empty($_GET[renew])) echo '<script type="text/javascript">
<!--
window.location = "managelisting.php"
//-->
</script>';

?>

Link to comment
https://forums.phpfreaks.com/topic/240829-classified-ad-script-help/
Share on other sites

You could run a cron that deletes free ads over 2 days old every night.

 

You could simply only serve data that's newer than two days.

 

SELECT `columns` FROM `table` WHERE DATE_SUB(NOW(), INTERVAL 2 DAY) < `dateColumn`

 

I am not very good in PHP script if you could give me some more detail how to do this?

So you don't understand how your script works?

 

This is a forum for PHP programmers. If you need help with someone else's code there are other places to find help. The freelance forum is a good start, though you may actually have to pay to get someone to code for you.

So you don't understand how your script works?

 

This is a forum for PHP programmers. If you need help with someone else's code there are other places to find help. The freelance forum is a good start, though you may actually have to pay to get someone to code for you.

 

I purchased the script, and there is an admin panel where i can choose when the free listings will be deleted. But they are only deleted by action, not automated. The code snippet should be all the help I need to solve this issue.

I suggest going to the company that provided you the script for support then.

 

If you don't mind paying them for the time they spent coding, why is it an issue to pay someone to add functionality? I'm not trying to be a jerk here, but with the information I've provided and Google, someone with knowledge of how the script works could easily make the changes.

 

On top of that, the code you've provided is pretty thrown-together. Simply trying to separate the logic from the markup will take time. Keep in mind that in order to provide you with code you can just 'throw' in there we have to figure out how your script works - especially considering you, as the person requesting help, is unable to help up decipher exactly what's going on, or what functionality is provided by what code-block.

 

You need to get the creators to help you with this, or hire someone to do it. If someone here does it voluntarily, I really hope you decide to PayPal them a bit of cash, cause there could easily be an hour's work in providing even the most hacked-together solution to your problem.

 

Have you even read into what a CRON job is/does? Perhaps showing us some remote form of effort will encourage someone to spend time solving your problems.

I suggest going to the company that provided you the script for support then.

 

If you don't mind paying them for the time they spent coding, why is it an issue to pay someone to add functionality? I'm not trying to be a jerk here, but with the information I've provided and Google, someone with knowledge of how the script works could easily make the changes.

 

On top of that, the code you've provided is pretty thrown-together. Simply trying to separate the logic from the markup will take time. Keep in mind that in order to provide you with code you can just 'throw' in there we have to figure out how your script works - especially considering you, as the person requesting help, is unable to help up decipher exactly what's going on, or what functionality is provided by what code-block.

 

You need to get the creators to help you with this, or hire someone to do it. If someone here does it voluntarily, I really hope you decide to PayPal them a bit of cash, cause there could easily be an hour's work in providing even the most hacked-together solution to your problem.

 

Have you even read into what a CRON job is/does? Perhaps showing us some remote form of effort will encourage someone to spend time solving your problems.

 

I can not go to the company with support, because they never reply back to me via email.

 

I know what a CRON job does, but I do not how to execute a cron job to delete listings that are over 2 days old.

 

I would be willing to pay someone some paypal money if they helped with this issue.

A CRON job can be used to execute a PHP file from the command line.

 

A PHP file that executes a query similar to the following

 

DELETE FROM `table` WHERE `date` < DATE_SUB(NOW(), INTERVAL 2 DAY)

 

Should delete all entries with a date column older than two days.

 

Post this over in the Freelance forum. Someone will jump on it :)

 

Thanks for not getting angry. It's just your request seemed more like a code-for-me than a help-me-with-code, and I see far too many of those in here :D

 

This will help you get started if you want to do it yourself

 

http://www.tizag.com/mysqlTutorial/mysqlconnection.php

http://www.tizag.com/mysqlTutorial/mysqldelete.php

A CRON job can be used to execute a PHP file from the command line.

 

A PHP file that executes a query similar to the following

 

DELETE FROM `table` WHERE `date` < DATE_SUB(NOW(), INTERVAL 2 DAY)

 

Should delete all entries with a date column older than two days.

 

Post this over in the Freelance forum. Someone will jump on it :)

 

Thanks for not getting angry. It's just your request seemed more like a code-for-me than a help-me-with-code, and I see far too many of those in here :D

 

This will help you get started if you want to do it yourself

 

http://www.tizag.com/mysqlTutorial/mysqlconnection.php

http://www.tizag.com/mysqlTutorial/mysqldelete.php

 

Well, good news! I did it myself, I didn't think I had it in me, it works great! Hahaha.

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.