Jump to content

akitchin

Staff Alumni
  • Posts

    2,515
  • Joined

  • Last visited

    Never

Posts posted by akitchin

  1. for the record (and future form design), it would have been far more straightforward to process these values the way you wanted if you used an array key in the name, rather than an iterative variable tacked onto the end of your name:

     

    <td align="right">Name:</td>
    <td align="left"><input type="text" name="name[1]" value="" size="25" /></td>
    <td align="right">Email:</td>
    <td align="left"><input type="text" name="email[1]" value="" size="25" /></td>

     

    what this allows you to do is iterate through one of the $_POST arrays, and use the key to identify its partner:

     

    $paired_data = array();
    foreach ($_POST['name'] AS $key => $this_name)
    {
      $this_email = $_POST['email'][$key];
      $paired_data[$key] = array('name' => $this_name, 'email' => $this_email);
    }
    print_r($paired_data);

     

    the php manual has some pretty good information on arrays here, if you're still quite new to them.

  2. have you created the "/whatever" folder where it should be, and properly set permissions for it? if so, i would guess that it has something to do with the user that the FTP script is operating as not having appropriate permissions to access directories above the web root.

  3. if you've got all the report IDs in the $_POST['reports'] array, you can collect them into one string and SELECT all of the report info from the db:

     

    $rid_list = implode(',', $_POST['reports']);
    $query = "SELECT * FROM reports WHERE ID IN ($rid_list) ORDER BY whatever";

     

    to get the total price, you can simply add each individual report price to a total as you display them.

  4. you'll want to do two things (if you want to use that function). the first is to modify your query to use a function that will convert your timestamp column into a UNIX timestamp:

     

    SELECT date_part('epoch', timestamp_column_name) AS UNIX_timestamp FROM table

     

    second, you'll need to adjust the function so that you can pass it a timestamp, rather than it assuming you want the current date/time. this involves putting a parameter in the function which has a default value when not specified:

     

    function FullDateAndTimePortuguese($timestamp = time())
    {
      setlocale(LC_ALL, NULL);
      setlocale(LC_ALL, 'pt_PT');
      $DayOfWeek = ucfirst(gmstrftime("%A %d %b %Y %H:%M", $timestamp));
      return $DayOfWeek;
    }

     

    then you can use the function to format your date and time:

     

    $formatted_date = FullDateAndTimePortuguese($timestamp_from_query);

  5. it's impossible to know for sure, since this function is user-defined (ie. not a native PHP function) and therefore we don't know how it's supposed to work. however, i'm going to take a stab and say that the parameter after date("Y")-18 is the upper boundary. try changing that one to date("Y")-15 and see what you get:

     

    selectList( "field_4_YYYY", $_POST["field_4_YYYY"], date("Y")-18, date("Y")-15, "YYYY", $style ) ;

  6. $days = time() -  60*60*24*7  // 7 DAYS

    $sql="SELECT folder FROM photos WHERE published=3 AND timestamp > $days";

     

    maybe this is better??

    I wrote it on the fly and isn't tested but looks right to me (most things that fail do work in my head but i'm tryin :D)

     

    the row's timestamp should still be LESS THAN the timestamp from 7 days ago in order to be older.

  7. you need to put parentheses around the subtraction expression. otherwise, php concatenates the current timestamp onto the string, and then attempts to subtract 7*24*60*60 from the string itself.

     

    when in doubt, always echo the query to see if it contains what you think it should.

  8. so, would this work:

     

    $sql="select folder from photos where published=3 and data>".time() - 7*24*60*60;

     

    I am not sure if I have my syntax right, but I think that will select folder from photos where published is 3 and data is (the current time) -7 days.

     

    have you run this to see what you get?

  9. you're using all double-quotes. on the first line, when the echo statement reaches the second ", it think it's done echoing. so it wonders just what exactly you're trying to do after the echo.

     

    to fix it, either escape the double quotes within the echo statement, or convert the double quote delimiters to single quotes. have a look in the PHP manual about strings and variables.

  10. i suppose whoever wrote that line never saw the function time. anyhow, a UNIX timestamp is measured in seconds. in order to get the UNIX timestamp that was exactly 7 days ago, you simply need to subtract the number of seconds in 7 days:

     

    echo 'timestamp now is: '.time().'<br />';
    echo 'timestamp 7 days ago was: '.(time() - 7*24*60*60);
    // 7 days * 24 hours * 60 minutes * 60 seconds

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