Jump to content

davidannis

Members
  • Posts

    627
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by davidannis

  1. While on vacation I had a lot of downtime and my handy Nexus 7. I got tired of studying Japanese vocabulary and realized that my problem was that I needed to learn more grammar to go with my growing vocabulary. Being a glutton for punishment, I decided that the best way to learn grammar was to create a program that would teach it. So, I began writing and now my little program can spit out some grammatically correct sentences in both languages. Next step is to make it quiz me on the grammar and vocabulary. Which brings me to my big question. I would like to use a spaced repetition system to maximize retention. I've Googled a bit and learned some things. The Leitner System seems pretty easy to understand but I'm guessing that there are better algorithms around. Ideally I'd like PHP/MySql code that I could integrate with my app (My preference is procedural because I am less comfortable with OO), second choice is pseudocode that I could turn into code, third choice is a clear description of a better algorithm than Leitner. So, can anybody point me to code or examples? Does anyone have experience with flashcard algorithms and can make suggestions on a different method or tweaks to Leitner? Thanks, David
  2. You do not need a div tag. I used one but as mac_gyver suggests you can assign an id to an input tag like this. <input name="city" id="city" type="text"> Then just change the value of the input using javascript per mac_gyver's suggestion above.
  3. Hard to tell from your question but I think that what you want is: if (!(empty($_REQUEST['checkbox_name_here']))){ // do your implode here } You can change $_REQUEST to $_POST or $_GET if you know how form is submitted. http://www.php.net/empty
  4. I need to get away from this snow.

    1. Stefany93

      Stefany93

      Southerner ? :D

       

  5. AFAIK you need to serve it through a server if you want to mix html and php and display it in a browser. There are local servers you can install on Windows, Linux, and Mac. Google WAMP, LAMP, or MAMP to get apache, MySql, and PHP all bundled together and easy to install on your OS.
  6. You could use php's JSON implementation explained here: http://php.net/json_encode
  7. My pleasure. It's only an example. The biggest difference with what you are trying to do is that I send the entire section of the form that will be filled (the checkboxes) from the server using method_checks.php to build it. You will probably just have the section of the form already on the page and just fill in the values. The reason I did it that way it that the number and values of the checkboxes is dynamic and I figured as long as I needed to build that section of the form on the fly I might as well do it once instead of twice. method_checks is server side. Yes, I think that Ajax/JS is the best and fastest way. I think that mac_gyver's suggestion of getting it to work without Ajax first is a good way to go.
  8. Here's some code I use on one of my websites to fill checkboxes based on a what is selected in a select list. Relevant sections of web page with select: //javascript <script> function chkMethods(str) { if (str == "") { document.getElementById("mthdboxes").innerHTML = ""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("mthdboxes").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", "method_checks.php?company_valuation_id=" + str, true); xmlhttp.send(); } </script> </head> <body onload="chkMethods('new');"><!-- to have checkboxes unfilled if a new one --> //form <form action="" method="POST"> <input type="hidden" name="pagesubmitted" value="select_company"> Choose a Valuation to Work On: <select name="company_id" onchange="chkMethods(this.value)"> <option value="new">Add a New Valuation</option> <?php echo $select ?> </select><br />Name (or rename) this valuation:<input name="valuationName" type="text"> <br /> <div id="mthdboxes">You need to enable javascript for this to work.</div> <input type="submit" value="Start or Resume Selected Valuation"> </form> and the relevant section of method_checks.php $company_valuation_id = mysqli_real_escape_string($link, $_GET['compnay_valuation_id']); if ($company_valuation_id != 'new') { $query = "SELECT * FROM company_valuation_methods WHERE company_valuation_id='$company_valuation_id'"; $result = mysqli_query($link, $query); if ($result) { while ($method_selected = mysqli_fetch_assoc($result)) { $methods[] = $method_selected['method_code']; } } else { $checkboxes = $query . '<br>' . mysqli_error($link); } } $query = "SELECT * FROM method_code WHERE 1 ORDER BY order_by"; $result = mysqli_query($link, $query); if ($result) { $checkboxes .= "<p> Which method(s) of valuation would you like to use for this report?"; while ($method = mysqli_fetch_assoc($result)) { $checkboxes .= "<br /><input type=\"checkbox\" name=\"method_code[]\" value=\"{$method['method_code']}\""; if (in_array($method['method_code'], $methods)) { $checkboxes.=" checked=\"checked\" "; } $checkboxes .=">{$method['method_desc']}"; } $checkboxes .='</p>'; } else { $checkboxes = $query . '<br>' . mysqli_error($link); //log error here } echo $checkboxes;
  9. Yeah, but I prefer to spend my time helping people who aren't actively working to make the world a bit more horrible.
  10. I don't think that this will work with international numbers or 1-800-666-5554 because you don't allow the 1- in front. Also, this does not allow spaces or parentheses or absence or dashes. I hate being forced to reinput a phone number because I didn't use the expected format. This article has a lively discussion of the issues and some code that might be worth a look at: http://www.reddit.com/r/PHP/comments/18j6k9/heres_a_function_to_reliably_validate_and_format/
  11. Indexes do not need to be unique, though you can require that one be unique. http://www.tutorialspoint.com/mysql/mysql-indexes.htm or if you have phpMyAdmin (which I highly recommend) http://www.siteground.com/tutorials/phpmyadmin/phpmyadmin_database_management.htm
  12. not sure what the validation issue is. I get no response from the form. when I submit it. The code <?php header ('Location: http://ebusinessbpo.com/cebucallcenter/thankyou.html'); ?> redirects me. Are you sure you have the line right? If you do, you are not getting to the success message. Please wrap your code in code tags so it doesn't convert urls to links and its readable. (the <> in the editor). BTW: On your form the confirm details checkbox should be removed and the idea that the word details links to nowhere is really bad.
  13. It looks to me like it is working on the live site, but only using the model number not the brand. You need to use both and with an or condition, not concatenated. So if I type Apple I get all apple phones and if I type iphone I get all iphones. I'm guessing you are trying to add brand to the search. I'm guessing the speed issue is because brand is not indexed. I think that your where clause needs to be WHERE brand LIKE %$q% OR model_number LIKE %q% OR concat (brand, ' ',model_number) like '%$q%' Make sure that you define indexes on barnd, model_number, and create an index that has both. A lot of guesses in my answer. Sorry if it doesn't work.
  14. Sorry about the misplaced )
  15. instead of echo( SUCCESS_MESSAGE ); use header ('Location: http://ebusinessbpo.com/cebucallcenter/thankyou.html'); to redirect. Change the URL to wherever you want the page to go.
  16. I don't see the problem. Do you have the original code that worked (albeit slowly)? Why does this posted example EG %iphone%%3g%8gb have two spaces in the middle. Are you using % signs just in the post so that we can see spaces or are they in the data? One idea would be to try using a full text search which would take care of sapces http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html
  17. How about something like this: session_start(); if($_REQUEST['usr']=="AINSCOUGH" && $_REQUEST['pswd']=="*****"){ $_SESSION['usr'] = "AINSCOUGH"; $_SESSION['pswd'] = "******"; $_SESSION['type']="this"; header("Location: ../accounts/AINSCOUGH/location.php"); } elseif($_REQUEST['usr']=="AINSCOUGH" && $_REQUEST['pswd']=="*****"){ $_SESSION['usr'] = "AINSCOUGH"; $_SESSION['pswd'] = "******"; $_SESSION['type']="that"; header("Location:../accounts/AINSCOUGH/SiteName/Teesside/showfolders.php"); } Then on pages you want anyone to see: session_start(); if(!isset($_SESSION['usr']) || !isset($_SESSION['pswd'])){ header("Location: /index.php"); } but on those you want to restrict only to users of type "this" (or "that") session_start(); if(!isset($_SESSION['usr']) || !isset($_SESSION['pswd'] || $_SESSION['type']!="this")){// change this to that if you want to require users of type that header("Location: /index.php"); }
  18. Don't see how this uses AJAX. Not sure why it is not returning results. Could you post some data from the database that you expect to be returned? Also, sanitize data that comes from a user's browser to keep hackers from taking over your site. use mysql_real_escape_string at the very least.
  19. One more thought, it is possible that you have an error in your php code (could even be in a part of the code that we're not seeing) and that error causes the script to fail but doesn't produce an error that we see in the browser. So, add the following to the top of the script: ini_set("display_errors", "1"); error_reporting(-1); See if you get an error message.
  20. I'm stumped too, but if I was going to try to debug it I'd do something like this: <?php $url="http://www.somewebsite.com/includes/ffl2.php";?> $.ajax({ type : 'POST', url : '<?php echo $url; ?>', to make sure it's not a missing / or something. Then, if it still did not work I'd view source in my browser and cut and paste the echoed value of $url into the browser's address bar and see if I got the expected response.
  21. The answer is in post #3 by ch0cu3r :
  22. The LIMIT 1 you have in the SELECT makes it only return 1 row http://dev.mysql.com/doc/refman/5.0/en/select.html
  23. How do you get the id for the SELECT before the prepare?
  24. the "error messages" you get are part of the code on your page. My theory is that Dreamweaver is messing things up causing your code to be output to your browser instead of being executed. Can you try just uploading the script without dreamweaver and see if it works?
  25. Do you have php on your Mac? Are you doing this testing on your local machine or on Yahoo's server? When you said I assumed that code was appearing in the browser. If that's not the case, you need to paste the code in post #11 in the top of your script, submit the form on a server, and paste what shows in the browser here. You can't fix errors if you don't know what they are.
×
×
  • 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.