Jump to content

Search the Community

Showing results for tags 'operators'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 4 results

  1. I thought I would add this topic since I'm in need of an answer and don't see much ternary used in code examples. Using a ternary operator to assign a file path to a local variable. The path string is conditional, depending on which page id was passed to the script. Once the $_GET variable is evaluated, I like to unset these variables as a personal "memory maintenance" preference (even though garbage collection is automatic). Would prefer to only call unset( ) if $_GET[pageid] is set. The second code block makes the issue clearer. Here is the code I've tried. It generates an error. $fpath = (unset(isset($_GET['pageid']))) ? "path/to/file2.txt" : "path/to/file1.txt"; //error Parse error: syntax error, unexpected 'unset' (T_UNSET) /* for comparison purpose, does same thing as above * but works as expected because ifelse construct * allows for stacking functions within a code block. * where ternary seems to have a problem with unset(). */ if (isset($_GET['pageid'])) { $fpath = "path/to/file2.txt"; unset($_GET['pageid']); } else { $fpath = "path/to/file1.txt"; }
  2. I'm trying to get an equation from a user that types it in the url, ex) 1+2+3. I can get the 1,2,3 fine, but the + operator is no longer in the string. Same with the * and / operators. Is there a way to keep them as a string using $_GET?
  3. 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
  4. Another basic one for you. I just created a little script that asks the user for the current weight of their baby and when submitted it tells them how much breastmilk their baby needs per hour and per day. But the per hour numbers look like this (for example) 0.916666666667 How can I make it look like this: 0.9 ? Thanks!!
×
×
  • 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.