Jump to content

richardw

Members
  • Posts

    120
  • Joined

  • Last visited

Posts posted by richardw

  1. I too am not very familiar with "sprintf"....

     

    Definition and Usage

    The sprintf() function writes a formatted string to a variable.

     

    The arg1, arg2, ++ parameters will be inserted at percent (%) signs in the main string. This function works "step-by-step". At the first % sign, arg1 is inserted, at the second % sign, arg2 is inserted, etc.

    from http://www.w3schools.com/php/func_string_sprintf.asp

     

     

    Try adding a %s before the formmatted_date:

    $query_rsOrders = sprintf("SELECT *, date_format(OrderDate, '%d %M %Y') as %s formatted_date FROM Orders WHERE OrderCustomerID = %s ORDER BY OrderID Asc", $colname_rsOrders);

  2. Well, I looked at the schema and script, and decided to redo it as I would have programmed it, you may want to change it back to meet your programming technique, but if this seems to work, modify it slowly so that you can see the changes...

     

    I set up a test DB w/tables at http://www.mywebforyou.com/join_test.php, and I do get different dates with my test data using two tables on a left join:

     

    <?php
    $dbname =  "YourDBName";
    $hostname = "localhost";
    $dbuser = "YourUserName";
    $dbpassword = "YourPassword";
    $db=mysql_connect($hostname,$dbuser,$dbpassword);
    mysql_select_db($dbname) or die("Unable to connect to the database");
    $sql = "SELECT *, date_format(OrderDate, '%d %M %Y') FROM orders LEFT JOIN customers  ON orders.OrderCustomerID = customers .CustomerID ORDER BY orders.OrderID";
    $result = mysql_query($sql); 
    ?>
    <?php
    while ($row = mysql_fetch_assoc($result)) { 
    echo $row["date_format(OrderDate, '%d %M %Y')"]," ", $row["OrderTotal"]," ", $row["FirstName"]," ", $row["LastName"]," id=", $row["CustomerID"]; 
    ?> 
    <?php
    echo "<br>";
    } 
    ?>

     

    I hope this helps you re-work your script to meet your needs.

     

    best,  :)

  3. hi! If you paste your output into notepad as I did, then select the " " (sapce) with the mouse, got to replace, and paste the space into the "Find What" area, although you will see nothing the cursor will move, next insert the delimeter into the  "replace with" and then select replace all. Now save your file as a "txt".

     

    Keep note of your field order, and in the phpmyadmin "Insert textfiles into table" option, enter the respective field names of your database  to  match the .... "If you wish to load only some of a table's columns, specify a comma separated field list." 

     

    Give it a try... it works and may sound more difficult than it is.  :)

  4. Add this in the head tag...

     

    <META HTTP-EQUIV="Refresh" CONTENT="30;URL=javascript:self.close()">

     

    Although this works, browsers may interpert this the wrong way and inform the user of an outside influence before colsing. Not recommended unless its a limited audience that you know. If you do use it, change the 30 which is this time in seconds. (not PHP, but javascript)

     

    Best

  5. I just used notepad and replaced the space with the ";"  . Now you can upload this directly using phpmyadmin

     

    20070205193000;2007-Feb-05;19:30:00;18.4;2.5;0.7;54;88;0.0;112.5;ESE;-1.00;2.5;0.00;1012.800

    20070205193500;2007-Feb-05;19:35:00;18.4;2.4;0.6;54;88;0.0;135.0;SE;-1.00;2.4;0.00;1012.800

    20070205194000;2007-Feb-05;19:40:00;18.4;2.2;0.4;53;88;0.0;90.0;E;-1.00;2.2;0.00;1012.800

    20070205194500;2007-Feb-05;19:45:00;18.4;2.1;0.3;53;88;0.0;112.5;ESE;-1.00;2.1;0.00;1012.900

    20070205195000;2007-Feb-05;19:50:00;18.4;2.0;0.2;53;88;0.0;135.0;SE;-1.00;2.0;0.00;1012.900

    20070205195500;2007-Feb-05;19:55:00;18.4;1.9;0.1;53;88;0.0;157.5;SSE;-1.00;1.9;0.00;1012.900

    20070205200000;2007-Feb-05;20:00:00;18.5;1.9;0.1;53;88;0.0;112.5;ESE;-1.00;1.9;0.00;1012.900

    20070205200500;2007-Feb-05;20:05:00;18.6;1.9;0.1;53;88;0.0;135.0;SE;-1.00;1.9;0.00;1012.900

    20070205201000;2007-Feb-05;20:10:00;18.6;1.9;0.1;53;88;0.0;112.5;ESE;-1.00;1.9;0.00;1012.900

    20070205201500;2007-Feb-05;20:15:00;18.6;1.8;0.0;53;88;0.0;135.0;SE;-1.00;1.8;0.00;1012.700

    20070205202000;2007-Feb-05;20:20:00;18.7;1.8;0.0;53;88;0.0;90.0;E;-1.00;1.8;0.00;1012.700

    20070205202500;2007-Feb-05;20:25:00;18.7;1.6;-0.2;53;88;0.0;112.5;ESE;-1.00;1.6;0.00;1012.700

  6. Did this come right from the other page, or is it reconstructed to resemble it. One item I use whwn uploading and posting is to add the form type  "enctype="multipart/form-data" to the form definition.

     

    If this you are using the same script as the one you point to, can you provide a link to where I can download it and scan for differences.

     

    best    :)

  7. Hello! Just add a date field to the table structure and make sure its a timestamp. Take the date field out of your form, and if you have only one timestamp field, it will automatically have the date the form is submitted. Make sure this is not the date field in your form, or it will provide an empty timestamp the way your INSERT statement is currently configured.

     

    Let me know if I can clarify this further. You will always be able to retrieve the timestamp and format it as you wish in your reports.

     

    :)

  8. When I viewed it in code I saw sapce tags added... not sure why, but heres the code again... Make sure to set the year to your time frame.

     

      <select name="month">

    <option value="<?php echo date ("F", mktime()) ?>"><?php echo date ("F", mktime()) ?></option>

    <option value="January">January </option>

    <option value="February">February </option>

    <option value="March">March </option>

    <option value="April">April </option>

    <option value="May">May</option>

    <option value="June">June</option>

    <option value="July">July</option>

    <option value="August">August</option>

    <option value="September">September</option>

    <option value="October">October</option>

    <option value="November">November </option>

    <option value="December">December </option>

    </select>

    <select name="day">

    <option value="<?php echo date ("j", mktime()) ?>"><?php echo date ("j", mktime()) ?></option>

    <?php

    for ($x=1; $x<=31; $x++) {

        print "\t<option";

        print ($x == $year)?" SELECTED":"";

        print ">$x\n";

    }

    ?>

    </select>

    <select name="year">

    <option value="<?php echo date ("Y", mktime()) ?>"><?php echo date ("Y", mktime()) ></option>

          <?php

            for ($x=2005; $x<=2006; $x++) {

            print "\t<option ";

    print ($x == $year)?" SELECTED":"";

              print ">$x\n";

            }

              ?>

    </select>

  9. A decision has to be made if the game scores are ALWAYS added the day of the game, or at a later date. This will impact the logic of being able to use today's date versus a date of two days ago, in which case you need user input. If you have a games schedule, maybe you could explore using a join and update the field automtaically.

     

    Otherwise consider using a second date field, just for the day it was played. It does not have to be a timestamp, for example:

     

       <select name="month">
    <option value="<?php echo date ("F", mktime()) ?>"><?php echo date ("F", mktime()) ?></option>
    <option value="January">January </option>
    <option value="February">February </option>
    <option value="March">March </option>
    <option value="April">April </option>
    <option value="May">May</option>
    <option value="June">June</option>
    <option value="July">July</option>
    <option value="August">August</option>
    <option value="September">September</option>
    <option value="October">October</option>
    <option value="November">November </option>
    <option value="December">December </option>
    </select>
    									 <select name="day">
    <option value="<?php echo date ("j", mktime()) ?>"><?php echo date ("j", mktime()) ?></option>
    <?php
    for ($x=1; $x<=31; $x++) {
       print "\t<option";
       print ($x == $year)?" SELECTED":"";
       print ">$x\n";
    }
    ?>
    </select> 
    <select name="year">
    <option value="<?php echo date ("Y", mktime()) ?>"><?php echo date ("Y", mktime()) ></option>
         <?php
            for ($x=2006; $x<=2010; $x++) {
            print "\t<option ";
    print ($x == $year)?" SELECTED":"";
              print ">$x\n";
            }
              ?>
    </select> 

     

    Hope this clarifies options :)

  10. you can assemble a timestamp from the following type of input:

     

    02-06-2007  ( a format utilized by many pop-up javascript calenders -- or you can force input into that format with a mask. ) Place this code after your submit string, but before the INSERT string. If you have only one timestamp field, and the date is left blank, it will default to today. If you create a second timestamp field for this string, your default field will show you the date the record was added.

     

    $daystring2 = $Date;

    $month = substr($daystring2, 0, 2);

    $day = substr($daystring2, 3, 2);

    $year = substr($daystring2, 6, 4);

    $fill = "000000";

    $begindate  = $year.$month.$day.$fill;    // this will be your timestamp

     

     

     

    Hope this helps,  :)

  11. try this, group the values, but your statement needed another field name in the OR

     

    <?php 
    $sql="SELECT * FROM `values` WHERE (`name` LIKE '%".$q."%') AND   (`category` = 'normal_rares' OR  `category` = 'seasonal_rares' ORDER BY `rd` DESC LIMIT 15";?>
    

     

    Hope this works...  :)

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