Jump to content

phppup

Members
  • Posts

    644
  • Joined

  • Last visited

Everything posted by phppup

  1. @Requinix I did say I was going to avoid the drama, but your one line uninformative respondes make it apparent that you thrive and require drama. So here we go: No, START is not a function. The name $start was used in the post to simplify the matter and make it obvious to readers (with the exception of Requinix) of what I was trying to accomplish. Do I need a function? The name of the field (as indicated) is "new date". It is written as one word in all lowercase letters. Got it now??? I don't want to nitt-pick, but 4 questions and a single line that might address 3 is pretty impressive from you. Care to elaborate or torch on the 4th portion?
  2. It all looked so simple on paper... But I'll skip the drama and get right to it: I'm posting $start and want to post $finish as a date that's 3 days afterwards Apparently, this is wrong somewhere: $finish = start('d-m-Y', strtotime($start. ' + 3 days')); echo $finish; On a similar note, I used some script to successfully change mm-dd-yyyy to Y-m-d. echo $newdate; works fine. But POST[$newdate] is not connecting. Any easy answer? And while on the subject, after all this DATE work, I opened Firefox using a form with an HTML input type=date. It displayed mm/dd/yyyy to the user, but intuitively echoed yyyy-mm-dd. Is this a benefit of Firefox or HTML? Is it trusted? Reliable? Will the feature work as default in other browsers?
  3. Got it working. Thanks for all the support.
  4. Note: My hosting service has said the server is fine and the problem is within my code. Does anyone see an issue or have any suggestions?
  5. I'm lost. Please be more specific with detailed instructions, if you would.
  6. I added this immedately after my <? but got nothing.
  7. My form is not posting data to table. I removed all validation to simplification purposes, yet onSubmit only provides a blank page. I have used a script and verified connectivity to the db, and feel as if there is something wrong with my INSERT statement. Here is my code: my_form.php <table width="300" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="POST" action="insert_file.php"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td colspan="3"><strong>Insert Data Into mySQL Database </strong></td> </tr> <tr> <td width="71">Name</td> <td width="6">:</td> <td width="301"><input name="name" type="text" id="name"></td> </tr> <tr> <td>Lastname</td> <td>:</td> <td><input name="lastname" type="text" id="lastname"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> </td> </tr> </table> insert_file.php <?php $host="localhost"; // Host name $username="provided"; // Mysql username $password="provided"; // Mysql password $db_name="provided"; // Database name $tbl_name="provided"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get values from form $name=$_POST['name']; $lastname=$_POST['lastname']; $email=$_POST['email']; // Insert data into mysql $sql="INSERT INTO $tbl_name(name, lastname, email)VALUES('$name', '$lastname', '$email')"; $result=mysql_query($sql); // if successfully insert data into database, displays message "Successful". if($result){ echo "Successful"; } else { echo "ERROR"; } // close connection mysql_close(); ?> Do you see something that I've missed??
  8. @Requinix:"Most effective way" to do what, exactly? To work with TIME in general. It seems JS requires manipulations from milliseconds in order to adopt user friendly information. PHP/MySQL appear to be able to accommodate 'real dates', so I avoid an added headache. I'd this a fair assessment? "I shouldn't have to explain why" Perhaps not. But would it hurt if you did? Obviously I'm on the right track because I made the comparison. Èqually obvious is my lack of clarity on the subject because I asked the question. I created my screen name to indicate that I was new and (while eager to grow) still bumping into walls and making (what the more experienced would consider) silly mistakes. The screen name had nothing to do with my affection of canines. "Informative and sensative responses will educate and empower the website capabilities while reducing recycled post volume." Me.
  9. I am planning to use a JQuery datepicker as an easy user interface on a form. This will identify a "start date" that the user will select for his 5 day work shift. The data will go into a table and other calculations will use this start date going forward. What is the most effective way to handle and manipulate this data for this situation? Is there a benefit or best practice? Is it better to format date information using JavaScript on the client side, or with PHP? Should I insert a date as mm-dd-yyyy or yyyy-mm-dd, or something else. Does it even matter? Any helpful hints and opinions to point me in the right direction would be great.
  10. Would you believe that I was unsure of exactly how to make the PDO connection and that the reason I changed to a 'more comfortable' connection was because I could not get the PDO to work? Or do you think that I changed it just to elicit more problems as a means to continue this fascinating dialogue??
  11. OK. Of course, I wouldn't have changed it if I knew where to place the information for the PDO connection. So, let me ask, "where do I put the information so that the PDO-devoted code will connect? And, assuming it does eventually connect, I will be back to my initial question: How do I update the selected record?????
  12. Here's the code straight off the server (sorry, don't know how to encapsulate it). The code is not populating data, and offers no method for 'attaching" the the selected record for UPDATE (which was my initially issue) after dynamically searching the table. <?php //include 'db_inc.php'; $db = mysqli_connect("localhost", "MY_INFO", "MY_INFO", "MY_INFO"); //$db = pdoConnect>>>> REMOVED // AJAX PROCESSING BIT if (isset($_GET['custname']) && trim($_GET['custname']) != '') { $stmt = $db->prepare("SELECT customer_id , fname , lname , phone FROM customer WHERE lname LIKE ? ORDER BY lname, fname, phone"); $stmt->execute( [ $_GET['custname'] . '%' ] ); $opts = ''; foreach ($stmt as $r) { $opts .= "<option value='{$r['customer_id']}'>{$r['fname']} {$r['lname']}, {$r['phone']}</option>\n"; } exit($opts); // return the options as the AJAX response } // report the selected customer if (isset($_POST['customer'])) { echo "You selected customer #{$_POST['customer']}<br><hr>"; } ?> <html> <head> <meta name="generator" content="PhpED 18.0 (Build 18044, 64bit)"> <title>Sample AJAX</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript"> $().ready( function() { $("#custname").keyup( function() { $.get( "sample_ajax.php", { "custname" : $(this).val() }, function(resp) { $("#customer").html(resp); }, "TEXT" ) }) $("#customer").change( function() { $("#fm1").submit(); }) }) </script> </head> <body> <form id='fm1' action="" method='post'> Enter last name<input type="text" name="custname" id="custname" size="20"> <br><br> <select name='customer' id='customer' size=10 > <!-- ajax response text goes here --> </select> <br><br> </form> </body> </html>
  13. For code that does not work, the attempt is appreciated, but not as much as a reply that resolves my issue. Your code did not work. Nor did it address the problem ( (as no update option was included. AJAX seems like a nice way to view data in my table. But I need a way to utilize it. Is there a way to Cchoose aspecified record and UPDATE it?
  14. After several attempts of adjusting this code and creating database tables, it appears not to work and has failed. Perhaps I should rephrase: hope do I use the selected item from an AJAX generated search so that the specific record can be updated in its table? Any helpful info, links, examples would be appreciated.
  15. This looks similar to what I've got: another AJAX developed menu. So, back to my question: after I make a selection, how does I carry the values and UPDATE the record? EG: I select John Smith with tele 5554321 and need to change his girlfriend's name from Mary to Wanda. I need to be able to UPDATE the correct corresponding record.
  16. Please re-read my initial entry. The dropdown-style is created with AJAX pulling data from the columns in distint rows (whether 'name' and 'phone' or 'state' and 'abbrev'). I created the following as a way to see it. function Delta(){ var x = document.getElementById("typ").value; document.write("You selected <b>" + x + "</b> as your choice."); In what manner would I use you suggestion as an alternative??
  17. The AJAX that I've got is end result of several suggestions and resources. The full story and it's reality for an end result may untangle the confusion. I have a form for customer information that inputs data into a table. That works fine. This customer information corresponds to other related data (ie. last sale, amount, etc.) through a non-disclosed index number. Since there is a likelihood that a 'first name' and 'lastname' may be duplicated (more than one John Smith), it is imperative that the correct record be updated. Enter AJAX, which enables user to enter keystrokes that narrow the field of John Smith's dynamically. The Smithers, Smithsons, and Smithers have been visually eliminated from the dropdown-style display. Now, there are three John Smith choices. In addition to 'firstname' and 'lastname' is 'phone'. This can be used to validate that from the choices, the correct John Smith is selected (with the associated [hidden] index. Great up to here. The table is populated, the data is dynamically visible. John Smith with'phone' 5551224 is selected. And then, NOTHING HAPPENS. I need to carry the 'phone' or the index to the next phase in order to update his girlfriend's name or add today's sale data. This is where I've stalled.
  18. Ummm, no. I posted originally in PHP and the post got moved to this forum. I would prefer a PHP solution (but will try this for educational purposes). Still would like the PHP method. Thanks for the help.
  19. Even if I stagger the execution intervals of job 1 and 2, there would be no guarantee during a presentation that there is no delay, at which point cron2 would run before cron1. Unless my thinking is wrong, I would like to run cron1 and incorporate something similar to a js script saying "wait 5 minutes and execute cron2." Can this be done?
  20. In its current form, the script does nothing more than dynamically display information contained in the table. I want to be able to now utilize it. Knowing that California (as 'state') exists does me no good if I cannot select it to update 'abbrev'. This is only a template right now. Simplified plans would replace 'state' with 'customer' and 'abbrev' with 'satisfaction'. In that case, customer Smith would be selected from Ajax. His satisfaction with our service is a 10. Today, he was disappointed and the 10 needs to be UPDATED to a 3. Currently, I am unable to satisfy that criteria t through a form because I cannot 'grab' there variable information and retain it for page 3.
  21. The table (which has not been coded bc I realized this issue) would simply likely refer back to an identifying retirement 'id' with rows 'sale'(a positive number), 'credit' (a negative), and 'current_balance' (for the running total). Obviously, I could always SUM both columns and do basic math tho calculate a total. My problem is how to get to the last balance (in the prior row corresponding to the particular 'id' and running a continuously updated cycle. In Excel it would be E2+C3-D3 to equal E3. My problem is getting to E2 (the last/previous sale record for this customer).
  22. After trolling the internet, I have managed to piece together enough information to accomplish the creation of a working Ajax script which dynamically shows the contents of a table column when a user types inside a text input field. So, the data from table STATES provides the 'name' field California and the 'abbrev' field CA. This seems to be accomplished when the first php files connects to the second php file through: $.get("backend.php", {term: inputVal}).done(function(data){ Now I want to put the selected information to use. How can I attach/connect 'name' or 'abbrev' so that these variables are selected in a third file update.php so that CA can be altered to "Cali" The input field displaying this info is name= 'typ' and I've managed to create a JavaScript: function Delta(){ var x = document.getElementById("typ").value; document.write("You selected <b>" + x + "</b> as your choice."); But this displays the information as a string. It seems like the long way around to use Java Script to disassemble the string and isolate each variable. And then, of course, I need to pass it to update.php Please help.
  23. How can I calculate a running balance using PHP? I have a table that will record both sales and credits and would like to display a cumulative balance. It seems redundant to have to revisit every individual transaction and recalculate the current balance each time it is required. How can I set up an additional column named "balance" and use it as a reference point against the newest entry for the specific customer? What is the best method of achieving a checkbook-style method?
  24. How can I calculate a running balance using PHP? I have a table that will record both sales and credits and would like to display a cumulative balance. It seems redundant to have to revisit every individual transaction and recalculate the current balance each time it is required. How can I set up an additional column named "balance" and use it as a reference point against the newest entry for the specific customer? What is the best method of achieving a checkbook-style method?
  25. I have created a Cron job that will send an email to new subscribers when they register. A second email will be sent a week later. For demonstration purposes, waiting more than a few minutes for the second email is not practical. Is there a way within PHP to set a timeout function, so that email number two can be initiated shortly after email number one?
×
×
  • 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.