Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7308633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:35:03+00:00 2026-05-28T23:35:03+00:00

First Part: I am trying to write a script to email us when a

  • 0

First Part:

I am trying to write a script to email us when a service call is not paid.

Heres’ what I have got started:

$query = "SELECT * FROM service";
        $result = mysql_query($query);  

    while($row = mysql_fetch_row($result)){

                $id = $row[0];
                $dateEntered = $row[1];
                $type = $row[2];
                $account = $row[3];
                $dateCompleted = $row[4];
                $notes = $row[5];
                $status = $row[6];

                foreach($status == 'Unpaid'){
                mailBadAction($id, $account, $status);

                }
        }   

I am not sure if I wrote the foreach right (probably didn’t, and I’m not in environment where I can just try it because its hooked into everything else.)

But basically, it will load all of the service calls in my while statement. I want to check each records $status, and check if it is ‘Unpaid’, and if so, run the function mailBadAction() and pass the $id, $account, $status, $dateEntered to the function. I only want this to happen ONCE a day.

Second Part:

I need this to run everyday at a certain time, once a day. I have zero understanding of cron jobs so I think that is out unless someone wants to help me out with that. But what I have learned is if I just include this page on the index or login page, it will run when someone simply hits the login page. But this will run it for every single time someone hits the index page.

Can someone help out?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T23:35:03+00:00Added an answer on May 28, 2026 at 11:35 pm

    As you are already in a loop, going though the results, so you don’t need a foreach, you just need if:

      if($status == 'Unpaid'){
                mailBadAction($id, $account, $status);
    
        }
    

    And if you are on a linux environment, you need cron to run something once a day.

    The easiest thing to do (if your system has it…), is add the php script to /etc/cron.daily and make it executable. Your script would look something like (depending on the environment…):

    #!/usr/local/bin/php
    <?php
    // your script
    ?>
    

    And you really should test it…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I trying to display image in picture box. The application have two part. First
I'm trying to write a Linq query which fetches all users whose first or
I have a couple of scripts for which the first part of them looks
I have been trying to write a set of htaccess rules that will do
I am trying to write a VBA script which imports all of the Excel
I'm trying to write a not so smart factorization program and trying to do
I'm trying to write a script that can control different windows from different programs
I am trying to write a python script to automate the process of checking
I'm trying to write a log parsing script to extract failed events. I can
Here is what im trying to achieve. I have a perl script that looks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.