
smoseley
Members-
Posts
433 -
Joined
-
Last visited
Everything posted by smoseley
-
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>";
-
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.
-
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?
-
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();;;
-
Your table1 design is incorrect. It should look more like this: id table2_id amount 5 1 12 5 3 3 5 5 7
-
Nope. Try searching for a free alternative: https://www.google.com/search?q=free+mysql+php+reporting+software
-
Copy Page From The Web And Upload It On My Server
smoseley replied to irshkur's topic in PHP Coding Help
file_put_contents('/path/to/file', file_get_contents('http://www.any-page-from-the-web.com')); -
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.
-
http://www.crystalreports.com/
-
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?
-
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.
-
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.
-
How To Search Through Multiple Json Files?
smoseley replied to codingbenn's topic in PHP Coding Help
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. -
How To Search Through Multiple Json Files?
smoseley replied to codingbenn's topic in PHP Coding Help
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. -
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.
-
SELECT tcs.tutor_id, tcs.category_id, tcs.subject_id, GROUP_CONCAT(s.subjects SEPARATOR ',') AS subjects, t.tutor_name, t.tutor_code FROM tutor_category_subject as tcs INNER JOIN subject AS s ON tcs.subject_id = s.subject_id INNER JOIN tutors AS t ON tcs.tutor_id = t.tutor_id WHERE s.subjects LIKE '%business%' GROUP BY tcs.tutor_id;
-
Populate Php Session Variable When User Clicks A Checkbox In Form
smoseley replied to MockY's topic in Javascript Help
Helpful... Why not? It's not a complicated thing he's asking for, and AJAX is a pretty simple concept... Your html page (requires jQuery): <input type="checkbox" id="checkbox_id" /> <script type="text/javascript"> $('#checkbox_id').change(function(box) { $.ajax('/update_session.php?checked=' + (box.attr('checked') ? 1 : 0) ); }); </script> update_session.php session_start(); $_SESSION['box_checked'] = $_GET['checked'] ? 1 : 0; -
How To Adjust The Position Of The Results Echoed By Php On My Site?
smoseley replied to dkar's topic in PHP Coding Help
+1 to Kira's solution. Missed the part that it was an AJAX load. -
How To Adjust The Position Of The Results Echoed By Php On My Site?
smoseley replied to dkar's topic in PHP Coding Help
There's no attachment. You really should post your code, too, to get help. The question as it stands is so abstract, the only help I could give you would be "Move the echo to the correct place in the HTML." -
Looking good. Only suggestion I have is to add a "New replies to your posts" link to the header again - that was my favorite feature of the old forum.
-
ALTER TABLE ilo_user ADD INDEX (zipcode); ALTER TABLE ilo_zip_codes ADD INDEX (zip); That'll make it go faster.
-
Completely unfair for you to relate entrepreneurship to gambling. "Idiot tax" is borderline offensive. My 2 cents. Why? Most small businesses fail ... Creating a new business is always a gamble. True enough, yet a 33% success rate over 10 years doesn't nearly equate to "lottery' or "idiot tax". Your previous post implies that anyone starting a business venture is a hopeless fool who is destined to fail. In other words, you waaaaayyy overstated your case. That may work for you, but there are 7 billion people on this planet, all different. Most are not "idea people", so "hitching their wagon to others' ideas" is not a bad prospect. Anecdote: A friend of mine built the software for someone else's company about 8 years ago, for a measly 25% of the company. A year later, he left his job as a programmer at FedEx, taking a pay cut to work on it full time. After 4 years, it was paying him a 6 figure salary. 2 months ago, they sold the business, and he cashed out for 7 figures. Not a bad prospect. Goes to show it works out for some.
-
Doesn't sound too interesting to me. I'm assuming there are 100 outstanding shares, and so after 5 years you'll be a 25% partner? Definitely sounds like they're trying to take advantage. What exactly have the other 3 guys contributed so far that your share requires 5 years of slavery to acquire? If they're structuring it as options, you should draw a salary during the 5 years. I'm assuming they each draw a salary already? By the way, sounds like a 1 year cliff... 5 year vesting period.
-
That all depends on the arrangement. There are many ways to arrange an equity deal. I've seen some crappy ones and some great ones. Equity without any payment is fine, as well. Again, as long as the other parties in the venture are investing an equivalent effort and/or cash contribution. Completely understood. You're not an entrepreneur. That's a completely acceptable attitude to have.... but.... Completely unfair for you to relate entrepreneurship to gambling. "Idiot tax" is borderline offensive. My 2 cents.
-
Well, it's a matter of mindset. If you're a mercenary focused on immediate payout, then maybe the question isn't really directed at you? My interpretation is that the poster is an entrepreneurial individual interested in the possibility of equity in a venture, and is looking for advice to that end from like-minded developers. Your pessimistic outlook on joint ventures, while providing a good caveat, is a bit harsh, in my opinion. Not every partnership opportunity is worthless.