paulmo Posted November 22, 2008 Share Posted November 22, 2008 pretty much a newbie with a website and some tutored php code, and mysql connection/table; reading about javascript and php frameworks, the capabilities seem very similar, so wondering: 1) can js do everything php can? interface with mysql? 2) after finishing reading php 6 and mysql (larry ullman), should i learn a couple frameworks (zend/jquery or yui) or just code from scratch? this for website with text responses from forms (want to expand to more variables and use functions which i know nothing about but seem cool, and eventually call database or third party info (google etc.) which would be edited according to form response values): www.releasecenter.org thanks for advice!! Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/ Share on other sites More sharing options...
JasonLewis Posted November 22, 2008 Share Posted November 22, 2008 As far as I know, JS can't connect to MySQL. That's what PHP does. You can request things from MySQL through PHP using AJAX. As for frameworks, I don't use a PHP Framework but I do use a JavaScript framework (jQuery). I only learnt the one JS framework though, thought that it would be enough. I guess it comes down to personal preference though. Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696026 Share on other sites More sharing options...
paulmo Posted November 22, 2008 Author Share Posted November 22, 2008 so php for database, and js for calling files and effects? can js insert/get values into/from another file(s) acting like database tables? on my site i've got js for date, capitalize first letter in name field, and third party geolocation. besides what i'm using and effects, what else is js useful for over php? from what i've read seems that js framework is a good idea and less use php framework. true? thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696153 Share on other sites More sharing options...
JasonLewis Posted November 22, 2008 Share Posted November 22, 2008 so php for database, and js for calling files and effects? can js insert/get values into/from another file(s) acting like database tables? You can use AJAX to make PHP and JS communicate. Which is where you see forums that tell you if your username is already taken before you submit the form. It simply uses AJAX to send a request to a PHP file that checks the database for the username you entered, then returns a value that you can check with JS and then set an image as either a tick or a cross. on my site i've got js for date, capitalize first letter in name field, and third party geolocation. besides what i'm using and effects, what else is js useful for over php? Well, they are hard to compare really. They are made for different things in mind. PHP acts on the server-side, so everything is done before it is displayed to the user. JS, however, is client-side. So JS can be used while the page is loaded. But JS can be disabled by the user, PHP can not. from what i've read seems that js framework is a good idea and less use php framework. true? I, and probably a lot of people, prefer JS frameworks. I don't use PHP frameworks though, its just a matter of personal preference. Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696160 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 On general remember this: JavaScript executes on client computer. So: 1. User has to download your code => keep your JavaScript files reasonably sized 2. User will see you code => don't put anything security related into JavaScript 3. User can modify your code => validate all data sent from browser using server-side scripts. And last but not least, if you have to do some calculations, better do them in PHP. You'll get results faster (in most cases). Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696171 Share on other sites More sharing options...
paulmo Posted November 22, 2008 Author Share Posted November 22, 2008 thanks, those comments are helpful. think i'm getting it...javascript can be used as a supplement to enhance php forms and user experience. but how about the main content? in php i've used cases, variables/values and switch statements. can these be done using javascript? or better to keep using php? Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696251 Share on other sites More sharing options...
corbin Posted November 22, 2008 Share Posted November 22, 2008 Just remember this: PHP should be used to output data to the client. Javascript can (not should) be used to manipulate the data sent to the client. The PHP script should never rely on JavaScript to make its output look right. Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696264 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 The PHP script should never rely on JavaScript to make its output look right. Unless you can tell your users, that they have to have JavaScript enabled in their browsers, or they'll be fired... Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696271 Share on other sites More sharing options...
corbin Posted November 22, 2008 Share Posted November 22, 2008 Eh yeah.... I guess I should revise my earlier statement to go something like: "You should try to avoid using JavaScript to make the output look a certain way, unless your site will definitely have to depend on JS." Then again, there are very few sites out there that can actually justify not having the site work with JS disabled. Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696362 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 I posted previous message, because I'm developing an intranet application, where all GUI is JS based. But I can afford it. Since its intranet, I say what browser to use and how to configure it. It sure makes thing easier. Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696378 Share on other sites More sharing options...
corbin Posted November 22, 2008 Share Posted November 22, 2008 Yeah.... I personally thing it's fine for some sites to depend on JS. For example, I don't know if facebook depends on JS or not (although I know it uses it a ton), but chances are, most people going there will have JS enabled, and if they don't, they will be willing to enable it, so they don't really have to worry about it. Also, if one of the major features of a site is actually it's use of JavaScript, then it's ok too. (Which is what it sounds like in your case.) Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696395 Share on other sites More sharing options...
paulmo Posted November 23, 2008 Author Share Posted November 23, 2008 PHP should be used to output data to the client. Javascript can (not should) be used to manipulate the data sent to the client. The PHP script should never rely on JavaScript to make its output look right. this really puts both in perspective—thanks. Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696619 Share on other sites More sharing options...
paulmo Posted November 23, 2008 Author Share Posted November 23, 2008 i've downloaded jquery. it's a js file on my desktop. trying to "run." microsoft jscript runtime error, 'window' is undefined. how to do this? thanks Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696636 Share on other sites More sharing options...
paulmo Posted November 23, 2008 Author Share Posted November 23, 2008 please disregard question above; found instructions, treat as external file. Quote Link to comment https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/#findComment-696643 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.