Jump to content

neobolt

Members
  • Posts

    13
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

neobolt's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. AHHHH, Thanks, something so small and simple. Much appreciated, everything works perfectly now.
  2. My url= http://sanitationhq.com/due-month.php?month=04 $selection_month = $_GET["month"]; $month = date('F', mktime(0,0,0,$selected_month,1)); echo "$month"; // Display December????? Not sure why. Try the url if you want to see.
  3. Thanks Barand, This gave me a really long digit as a number. I went with an if, elseif statement as a fix instead. if ($selection_month == '01') { $month = 'January'; } elseif ($selection_month == '02') { $month = 'February'; } elseif ($selection_month == '03') { $month = 'March'; } elseif ($selection_month == '04') { $month = 'April'; } elseif ($selection_month == '05') { $month = 'May'; } elseif ($selection_month == '06') { $month = 'June'; } elseif ($selection_month == '07') { $month = 'July'; } elseif ($selection_month == '08') { $month = 'August'; } elseif ($selection_month == '09') { $month = 'September'; } elseif ($selection_month == '10') { $month = 'October'; } elseif ($selection_month == '11') { $month = 'November'; } elseif ($selection_month == '12') { $month = 'December'; }
  4. I've been messing with this for a while now. I know I'm missing something simple. A user select a link which provides a 2 digit month code in the url. Example: website.com?month=04 My Code: $selection_month = $_GET["month"]; $month = date('F', strtotime($selection_month)); echo "Tasks Due for the month of $month"; Month always shows up as December. Should show as April for this example. What am I missing? Thanks John
  5. Thanks Barand, I got your solution to work perfectly but I had to remove one line of code: echo query2table($db, $sql); When I left this in the code I got an error: Call to undefined function. Thanks again. $db = new mysqli(HOST,USERNAME,PASSWORD,'test'); $sql = "SELECT id, start_date, frequency, IF(last_completed='0000-00-00', start_date, last_completed) as last_completed FROM mss ORDER BY start_date"; echo query2table($db, $sql); $maxDates = 5; // max no of dates to show $res = $db->query($sql); echo '<table border="" cellspacing="5">'; while (list($id, $sd, $freq, $lcd) = $res->fetch_row()) { $dt = new DateTime($lcd); $dt100 = new DateTime($lcd); $dt100->add(new DateInterval('P101D')); $di = new DateInterval("P{$freq}D"); $dp = new DatePeriod($dt, $di, $dt100); echo "<tr><td>$id</td><td>$freq</td>"; foreach($dp as $due) { echo '<td>' . $due->format('F d Y') . '</td>'; } echo '</tr>'; } echo '</table>';
  6. Hello, I not to confident with arrays but I'm sure one could be used instead of all the code I've written below. Any help or direction is appreciated. My database records have unique id's. Each id has a frequency in days in which they are due on a repeating basis. I would like to limit the amount of due dates displayed. Currently I am showing 8. Is is possible to limit the due dates shown based on a future date? Example: Show tasks due within the next 100 days. Some tasks with shorter frequencies(10 days) would show 10 due dates but tasks with say a 90 day frequency would only show one date. Here is what I have come up with so far: // Get all the data from the "mss" table $result = mysql_query("SELECT * FROM mss ORDER BY id ASC") or die(mysql_error()); while($row = mysql_fetch_array($result)){ // Calculates when the task is next due // If there is a last completion date then show next due date from this completion date. $calc_date = $row['last_completed']; //If there is no date for last_completion, then use the start_date to find next due date if ($calc_date == '0000-00-00') { $calc_date = $row['start_date']; } $due = date('F d, Y', strtotime($calc_date .' + '.$row['frequency'].' days')); $due2 = date('F d, Y', strtotime($due .' + '.$row['frequency'].' days')); $due3 = date('F d, Y', strtotime($due2 .' + '.$row['frequency'].' days')); $due4 = date('F d, Y', strtotime($due3 .' + '.$row['frequency'].' days')); $due5 = date('F d, Y', strtotime($due4 .' + '.$row['frequency'].' days')); $due6 = date('F d, Y', strtotime($due5 .' + '.$row['frequency'].' days')); $due7 = date('F d, Y', strtotime($due6 .' + '.$row['frequency'].' days')); $due8 = date('F d, Y', strtotime($due7 .' + '.$row['frequency'].' days')); $line = $row['id']. " - <strong>Next Due Dates: ". $due ." | ". $due2 ." | ". $due3 ." | ". $due4 ." | ". $due5 ." | ". $due6 ." | ". $due7 ." | ". $due8 ."</strong> <br/><br/>"; echo "$line"; } ?> Thanks John
  7. Amazing, Works perfectly. Thank you very much for the help. I'm still trying to wrap my mind around loops.
  8. Hello, What I am trying to accomplish: I have a table with values. I run a Select and create an array. I would like to make my script take the number 365(days) and divide by the value in the table(frequency). So lets say Frequency[0] is 14, the variable $total would become round(365/$row['Frequency']) = 26 The script would then loop and add the next value to the variable. Frequency[1] is 30, variable $total becomes 26 + (365/$row['Frequency']) = 26 +12 = 38 Loop would continue until all the frequency values are complete. Currently the script outputs each value individually, I need to make each value go through the division process then add together. Any help or direction is appreciated. Thanks. // Get all the data from the "mss" table $result = mysql_query("SELECT * FROM mss") or die(mysql_error()); include("header.php"); echo "<br/>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array($result)) { // Print out the contents of each row into a table $total = round(365/$row['Frequency']); echo "$total<br/><br/>"; } echo "$total<br/><br/>"; ?>
  9. Thanks guys for the responses. I got behicthebuilder's solution to work quite well. That's not to say it's the better solution, just for my little knowledge of php I understood this solution better. lol Thanks John
  10. Is there a better way to load table values into drop down menus? Basically I have 3 different drop down options which need to have data loaded into them from the same table in a database. Here is what I have so far. It works but I feel like there must be a better way to make this happen. <?php include("connect.php"); mysql_connect("$server", "$username", "$password") or die(mysql_error()); mysql_select_db("$database") or die(mysql_error()); // HEADER INCLUDE include("header.php"); echo "<br/><br/>"; echo "<form action='add-record2.php' method='post'>"; // GET ALL DATA FOR "LOCATION" FROM "ADMIN" TABLE $location = mysql_query("SELECT Location FROM admin") or die(mysql_error()); echo "Location:"; echo "<select name='location'>"; while($row = mysql_fetch_array( $location )) { echo "<option value='". $row['Location'] ."'>"; echo $row['Location']; echo "</option>"; } echo "</select><br/> Task Description: <textarea rows='4' cols='50' name='task'></textarea><br/> Responsibility: <select name='responsibility'>"; // GET ALL DATA FOR "RESPONSIBILITY" FROM "ADMIN" TABLE $responsibility = mysql_query("SELECT Responsibility FROM admin") or die(mysql_error()); while($row = mysql_fetch_array( $responsibility )) { echo "<option value='". $row['Responsibility'] ."'>"; echo $row['Responsibility']; echo "</option>"; } echo "</select><br/> Type: <select name='type'>"; // GET ALL DATA FOR "TYPE" FROM "ADMIN" TABLE $type = mysql_query("SELECT Type FROM admin") or die(mysql_error()); while($row = mysql_fetch_array( $type )) { echo "<option value='". $row['Type'] ."'>"; echo $row['Type']; echo "</option>"; } echo "</select><br/> Frequency(days): <input type='text' name='frequency'> <input type='submit'> </form>"; // END OF FORM ?> Thanks John
  11. Sorry. Thanks for your help it works perfectly! I forgot that I cleared my cookies earlier so the variables no longer had their values.
  12. <?php $header = $_COOKIE['mss']['header']; $body = $_COOKIE['mss']['body']; $footer = $_COOKIE['mss']['footer']; include $header; include $body; include $footer; ?> You mean like this? I still get the same error. Warning: main(): Failed opening '' for inclusion (include_path='.:/usr/local/lib/php') in /home/content/m/y/s/mystartspot/html/MyStartSpot/go.php on line 8
  13. <?php $header = $_COOKIE['mss']['header']; $body = $_COOKIE['mss']['body']; $footer = $_COOKIE['mss']['footer']; include '$header'; include '$body'; include '$footer'; ?> The variables don't seem to get input. I receive this error. Warning: main(echo $header): failed to open stream: No such file or directory
×
×
  • 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.