Jump to content

smoseley

Members
  • Posts

    433
  • Joined

  • Last visited

About smoseley

  • Birthday 04/14/1974

Contact Methods

  • Website URL
    http://www.tripadvisor.com

Profile Information

  • Gender
    Male
  • Location
    Boston, MA

smoseley's Achievements

Newbie

Newbie (1/5)

4

Reputation

  1. Maybe I misunderstood the request. I don't find that my suggestion was overly complex, though. AJAX isn't as difficult as people make it out to be. I stopped using double-quotes to echo HTML for the reason of being difficult to generate conventional double-quoted HTML, though I still do on occasion. My suggestions for echoing HTML, in order of preference (considering performance, and clarity of code): // 1 - Concatenated single-quoted text, for high performance in an HTML-generating loop echo '<div id="element">' . $dynamicContent . '</div>'; // 2 - Heredoc for multi-lined HTML echo <<<HTML <div id="element1">{$dynamicContent}</div> <div id="element2">{$dynamicContent}</div> <div id="element3">{$dynamicContent}</div> HTML; // 3 - HTML blocks with PHP echo short-tags for templating ?> <div id="element"><?=$dynamicContent?></div> <?php // 4 - Double-quotes with escaped double-quoted HTML, if you absolutely insist on double-quoted text in PHP echo "<div id=\"element\">{$dynamicContent}</div>";
  2. A lot gets lost in translation on a forum... I didn't mean to make this personal. You did mention your code... you said when you do it, it passes W3C validation. I simply meant to respond to that and state the facts as I understand them. There was no emotion in my post. There was no opinion. There was only fact. The fact is that it's a W3C recommendation to use double-quotes, and a common convention in every major web development shop in the world (that I'm aware of) to do so. Hope you understand I'm just trying to share my experience and help. Cheers.
  3. Single quotes are valid markup, but it's a w3c recommendation to use double-quotes, as some SGML parsers don't recognize single-quotes. It's also a standard convention in every development team I've ever worked in over the last 15 years to use double-quotes for HTML, and single-quotes for JS. If you want to do it backwards, go for it... but other coders will hate you and refactor your code so it fits conventions. If you actually read what the OP wants his application to do, he wants AJAX, whether or not he specifically asked for it by name. He wants it to "dynamically update the row when the box is checked." What was your interpretation of that?
  4. What you want is a simple AJAX update method. Easy enough to do. Change your input to this (I'm assuming your primary key is called "id"): <input type="checkbox" name="tasks[]" value="<?=$toq4p['id']?>" onclick="toggle(this)" /> (PS - always use double-quotes for HTML attributes... single-quoted HTML is a big no-no) Then add this javascript: (requires jQuery) function toggle(input) { input = $(input); $.ajax('/update_task_todo.php?id=' + input.value + '&todo=' + (input.checked ? 1 : 0)); } Then create the php script (update_task_todo.php) to update the record based on the id. <?php $id = (int) $_GET['id'];; $todo = (int) $_GET['todo']; $sql = "UPDATE tasks SET todo = {$todo} WHERE id = {$id}" mysql_query($sql); echo mysql_rows_affected();;;
  5. Your table1 design is incorrect. It should look more like this: id table2_id amount 5 1 12 5 3 3 5 5 7
  6. Nope. Try searching for a free alternative: https://www.google.com/search?q=free+mysql+php+reporting+software
  7. file_put_contents('/path/to/file', file_get_contents('http://www.any-page-from-the-web.com'));
  8. That script should not be placed inside a page. It should be its own PHP script (e.g. csv.php), which you would link to from another page.
  9. Gotcha. Misunderstood what you were saying (seemed like you thought there was no HTML involved). So you did this in PHP? Did you use Sablotron to do server-side transformation for browsers that don't support XSL-T?
  10. Seems pointless to me. It's like CoffeeScript, or Hibernate, or any ORM in existence. Abstraction of a common language for the sole purpose of making it "pretty" does 2 things: 1. it requires developers in your group to double their knowledge-base, and 2. it slows down a) deployment time, or b ) website speed EDIT: 3) It makes debugging a pain in the arse... because you have to manually map out the error in your translated code to the actual line of code that generated it.
  11. I'm assuming you didn't have your hands in the development of the XSL-T and aren't completely familiar with how it works. XSL-T transforms XML into another format. Very commonly, it's used as a templating scheme to transform XML into HTML, which is likely what your previous employer was doing.
  12. Actually, if you're gonna keep it file-based, I think keeping it as separate files and using grep would be the fastest solution. Cheers.
  13. Given your original architecture, grep would probably be the fastest way to do what you want: Something like: $name = $_GET["name"]; exec("grep '{$name}' /path/to/json/files/*.json", $result); foreach ($result as $line) { $filename = substr($line, 0, strpos($line, ':')); } However, I agree that a database is the way to go. You have enough data to justify it.
  14. Note: GROUP_CONCAT by default has a limit of 1024 characters. If you expect to exceed that, you should alter your my.cnf to change that.
×
×
  • 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.