Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Posts posted by phppup

  1. I don't mean to bother you with silly questions, but I must be using the wrong search terms to find any viable answers to this.

    Hypothetical situation:  I have a table [Customers] with with an auto-increment id, customer_name and email generated from a form.

    Now, I decide to expand my database to include customer-address and telephone number.

    I decide to create a second table named Contactinfo for this purpose (assuming this is a better database practice).

    As Customerinfo is generated, I want it to POST in association with the respective customer (assuming that 'id' is the best field for association).

    I need some examples and best practices to accomplish this.

    Examples, links, or preferred terminology would be great so I can attack this phase.


  2. Okay, got it.

    Yes, dates are in table.

    I believe I used SQL previously and this will add to it. If I'm not mistaken, I also used a PHP adaptation to test outside of the table (so that I could get comfortable with it and see results more easily).

  3. On a related note, I now have the basics to send a message to people listed in a database on their birthdate.

    It has occurred to me: what is the best way to deal with people with February 29 as their birthday?

    While the most simple solution would be to just forget them, that seems unfair. LoL

    Would the more practical approach be coding along the lines of:

    if(today +1) = March 1, then also include 2/29 from birthdate column? 

    Will something like that work? Is it practical? Is there a better way?

  4. I may implement it.  But I thank you either way.

    Just fiddling around, so it's not a major component of anything I am working with.

    And I'm actually happy to see that my own thought process to develop my own script to overcome this was along similar lines.

    Although yours is much, much cleaner and concise.

  5. At this point I clearly have too much time on my hands, as I started to tinker with different DATE options.

    $originalDate = 2003-03-03;   //March 3rd, 2003 is the day number 62 in that year
    $day_of_the_YEAR = date("z", strtotime($originalDate));    //provides the day of the year starting with ZERO on 01/01
    echo "($day_of_the_YEAR + 1)";      //allows me to ADD the ONE to compensate for the ZERO that begins the counter

    This is all OK, but then I tried to incorporate the English ordinal suffix by using the date format mechanism S.

    Not only did it not work, but when I edited my code to:

    $day_of_the_YEAR = date("zS", strtotime($originalDate));  
    echo "($day_of_the_YEAR)";  //because it won't work at all with the PLUS 1

    the result for echo $day_of_the_YEAR was 61rd  [which is neither accurate for March 3 nor acceptable as the correct English ordinal suffix.

    Is there a remedy, or is this due to trying to combine a non-date with the S switch?

  6. I have used an assortment of document.getElementBy.... to retrieve data

    If (document.getElementById('xyz').value >10) { do this... or that.. etc.

    I have a group of items with radio buttons and will assign a function if the element ID is A, perhaps a different function if the ID is B, or C etc.

    Now I want to assign an element by its CLASS.  How can I incorporate the desire that if the element's CLASS is "bluebackground" then alert("This is of blue background class")

    I had tried

    if(document.getElementsByClassName("bluebackground") == true) {
    alert("message of choice");

    And other variations, but something is not connecting.

  7. In a related problem (which is more PHP) , I now have a SELECT statement to generate a list of people with the same birthdate.

    I also have a formula that will calculate age with a birthdate from a form.

    How and where (in relation to the SELECT) do I place the adapted formula so that it uses the birthdate (stored in my table) to calculate the ages of the listed people with the given birthday?

  8. OK, after plugging in Kicken's corrections, things are working even better than expected.  

    Now my new problem is whether to use the birthdate 1 (transferred via JS and the hidden field) or birthrate2 (assembled by PHP on the server side).

    Too many choices.

  9. My apologies, and thanks.

    When I read Kicken's reply it appeared to me as if he had simply cut and pasted my original code as a reference. ( I actually couldn't figure out why he would do that, but I've seen people repost entire responses just to make a short comment.)

    However, now that I've reviewed it more closely, I have spotted the adjustments And will test them out.  


  10. Both kicken and maxxd: your telling me that I need to "change the value attribute on that input element, but your not explaining how I should do that.

    Obviously, if I knew how to remedy this correctly, I would have done so days ago. Please elaborate with an example.

    It's now an obstacle that I need to learn from.

    PS: for practicality, is it preferable to assemble these sort of elements on the server side? Why?

  11. Re-structured my code for a more streamline structure, but same problem.

    My THREE dropdowns that have names and ID's respectively as year, month, and day.

    My only use of JS

    function date_to_database()  {
          birthdate = 
          document.getElementById("year").value  + "-" + 
                 document.getElementById("month").value + "-" + 
               alert("The dob to be passed is: " + birthdate);

    I've also added ALERTS to each dropdown ONCHANGE to alert(dob)

    So I am effectively getting a visual confirmation of every instance that the date is effected.

    in HTML;        <input type="hidden" id="birthdate" name="birthdate" value="birthdate">

    My table now has two fields for birthdate1 and birthdate2

    And my PHP is designed as:

    $birthdate2= $_POST['year'].'-'.$_POST['month'].'-'.$_POST['date'];

    My result is: The birthdate1 column will only populate the VARCHAR field with the word "birthdate" (or whatever other static value I put as the hidden's value.

    The birthdate2 column will POST the correct information to the birthdate2 column.

    While I realize that using The birthdate2 provides a solution to the problem, I am still confused as to what is preventing the birthdate1 data from being passed from HTML as a hidden input.

    Answers?  Missed steps?  A break in the process?


  12. I think I may just re-work the entire script. It may be easier than tinkering with all the little problems, although I am making some interesting discoveries along the way.

    As for Jquery datepicker, it might be an interesting piece to toy with at a later date (no pun intended). LoL

  13. Created a separate button for onclick="function xyz()" and it ran the script and alert validation with no problem.

    But when I used SUBMIT, the same problem remained in that

    <input type="hidden" id="birthday" name="birthday" value="birthday"> 

     inserted the word 'birthday ' into the db  [i had changed it to a VARCHAR column so that ALL entries would be visible]

  14. Yes, the leading zeros are handled acceptably.  Maybe not exactly perfect, but good enough for now.

    I had thought of this, but considered the problem to be something more (although nothing alarming).  I'll give it another look and see if I can resolve it with this insight.

    I don't generally interact well with AJAX or JQuery, but I do like this particular Date Picker as an option (if I modify things later.... too committed to current code, right now.)  Here's a question: How can I tap into that Date Picker to add a feature for the person born in 1955 so I can ask if he knew he was born on a Tuesday?

    PS: the DatePicker sample seems to run from 1992 to 2012, so I would need to figure out how to adjust that for my purposes.

    And while we're tossing ideas around, I had considered bypassing the entire problem by POSTing year, month, and day to PHP and letting PHP reassemble the $birthday rather than using the JS.  Any thoughts or feedback on that methodology?



  15. I was going to open a new thread, but since MAXXD kept this one alive.....

    My JS code seems to be working fine, but for some reason the input to transfer the birthday to the db table is not making the connection from JS to the hidden input.

    function xyz()  {     // called onclick
        - - blah blah blah to add lead zeros - - 
      birthday = year.value + "-" + month.value + "-" + day.value;
    alert(birthday); //works fine and confirms format and correct date
    <input type="hidden" id="birthday" name="birthday" value="birthday"> 

    In my PHP a line was added:   echo $birthday;

    Along with the essentials to post into the db

    The above code will create a BLANK entry into the db after JS confirms in the alert that the correct data is available.

    <input type="hidden" id="birthday" name="birthday" value="2019-01-24"> 

    will confirm 2019-01-24 through echo $birthday and also add 2019-01-24 to the db field, even if 2001-07-04 was confirmed by JS from my form.

    What do I need to do to resolve the broken connection, please?

  16. Toying with different ideas.  For easiest explanation, I'll explain it this way:

    Let's say I have a HOMEPAGE with a button for color-swatches.  On-click, the button opens 4 new tabs that simply show the HTML color code with the entire page being that color (except for the font, obviously).  Each of the 4 would be different shades of red for the viewer to choose which is prettiest.  There is a risk of the objectivity being tainted if a viewer feels that the last page to open (in plain sight) is the "correct" choice.

    So, keeping the HOMEPAGE 'on top' would eliminate that prospect.

    Additionally, the HOMEPAGE might also have another button for shades of blue.

    Or even form fields to be filled out, so having it ready and primed would be more advantageous.

    Either way, it was just an aspect of exploration.

  17. I was more interested (since I've already established a date_of_birth field [without hours or minutes.. LOL] ...although it is tempting) in being able to use a query to determine whether TODAY() or NOW() is the birthdate.

    And, if true, then send a message saying "Happy $your_age birthday"  - - or something of the like.

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