How do I code a dynamic website? [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Never mind. I've found the correct answer

I think you have already all pieces in front of you, but don't know where to start.
I suggest that you
find an exciting Bootstrap blog template (like the free ones at Start Bootstrap)
understand the code, which is usually a good mixture of HTML5, CSS3, JavaScript with a modest use of jQuery
tweak it with your own ideas
if you have some special needs not covered by the template (for example collapsible menu items), you can browse the Bootply Snippet Library to look how others coded it.
Nowadays no web programmer starts from scratch. They choose a template with the basic structure of a one-pager, multi-pager, blog, e-commerce, etc. and start from there.
By the way: Alaboudi mentioned in his answer that you need to learn MySQL, too. This is indeed needed for dynamic content like e-commerce and blogs, but not for static content like business websites that don't change that often, but put an emphasis on individual page layouts.
But to get your first website up fast I would start with static websites and later extend your knowledge to MySQL.

Everything you have learnt is great, but you must also learn a database querying language (SQL). May I suggest you start learning MySQL, its very friendly for beginners. Now let me give you an example of how to code a dynamic website.
Lets consider facebook profile pages as an example. Firstly you must realize that there isnt 1 billion uniquely saved profile pages made for each user on the server. Rather, there is only 1 html css template that is filled in with appropriate information depending on the person loading the page. When the visitor comes to his profile page, his information must be queried from the database using a backend language (PHP in your case). Once the result of the call is retrieved, you fill in the appropriate information in your html (name, age, friends, blah, blah) and send it over to the user. So technically you are constructing the complete page with every call and you never actually have the complete page saved on the server.
Long story short, you should look into using a database.

This is not really a question. I would suggest you to go and code something.
You want to do a blog? Ok, try to do it with what you've learned so far.
When you'll start to build it, you'll have specific questions on specific problems, you can then search on Google your specific problem or come back to StackOverflow and ask for it.
Any resource is good and lucky you, there are plenty of resources on the internet ;)

Related

How should I make a poll for my website? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to make a poll for my website.The poll I want should look like the poll on http://www.premierleague.com/en-gb.html.I am not sure if I should use PHP,Javascript or etc to make a poll.Can anyone help me in this? Thanks...
You're going to need to create a form and receive the data on the server side using PHP. Then you're going to put that information into a database.
I hope I do not come across as too mean but, the decision on which language to use is pretty simple when compared to actually coding it. I'm betting you are not entirely experienced with web-based programming languages. I would strongly suggest you look for some pre-made scripts in the interim:
Here is a simple tutorial on creating polls: http://code.tutsplus.com/articles/creating-a-web-poll-with-php--net-14257
If you are OK with the idea of using a CMS, Here is a WordPress Plugin that should do the trick: http://code.tutsplus.com/articles/creating-a-web-poll-with-php--net-14257
Otherwise, it's important to understand the flow of data:
Display the poll to the end user (use HTML forms and CSS to style)
Client submits data (either built in submit functionality or Ajax)
Server Receives data and stores it into database (php)
Page is re-loaded and results are displayed (read with php, then displayed using html/css)
In other words, you are going to use many of the available languages and tools to create a polling script.
Start with a pre-built one and look up other resources to learn to make/customize your own.
If you need to save poll values, than PHP/MySql + JS for live effects, animations + CSS for styling.
Create database tables.
Create HTML form.
Style form to fit your needs (maybe jQuery UI).
Use Ajax to submit form.
Use PHP to gather information form user, validate it and save to database.
Reload user poll view to see changes.
Sell this masterpiece to Google/MS/Apple (or any other company).
Take big cup of hot chocolate.
Rule rest of the world.
Good luck.
Yes, you can use PHP or any server side scripting for validating, storing, processing poll, and use HTML/CSS/JS for client side, this is the main whole web page. You should also have DBMS (Database Management System) like mySQL, msSQL, etc., for storing poll answers.

How to add user reviews and ratings scores to my site? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am building an online store in ASP.NET Web Forms 4.0 and i would like to add a feature to it. I would like to add some user reviews(commentaries) to my products and some ratings scores.
Can someone help me on how should i implement these things ?
Is there on the internet any downlodable content(I didn't find
any) ?
Can you provide me some useful links on how should I implement
this ?
Any advice or tips and tricks ?
Ratings scores require javascript ?
Can someone help me on how should i implement these things ?
You can use jQuery, ASP.NET, SQL Databases mixed up with each other to create this system.
You will require HTML to create the stars, and then jQuery to handle the events (click dblclick etc) and sent the Ajax requests to the server.
ASP.NET would handle them all and save them or what so ever.
SQL Database would be required to save the data if required. This is the basic of this system to save and get the ratings by the user. You can use third-party plugins too. But creating one of your own would be the best option.
Is there on the internet any downlodable content(I didn't find any) ?
Internet is used by downloading Stuff, you even downloaded this page on to your browser. You didn't find any, or you didn't bother searching for it thoroughly? I bet you would have found good stuff.
Can you provide me some useful links on how should I implement this ?
I think this is the question that you are wrapping inside other text.
Here is a good tutorial from Mike Brind, that you might love too. http://www.mikesdotnetting.com/Article/114/jQuery-Star-Rating-with-ASP.NET-MVC
He is using ASP.NET MVC to let the user post the rating on his system. Posting a part of his code won't be good here. You need to use it all. Go there and learn it you will understand, he's a good teacher. Trust me.
Any advice or tips and tricks ?
Keep working out! You'll figure out the tricks and tips as you move. Until then, all that I can tell you is to learn the API and keep using and learning it through proper usage of them in your applications.
Ratings scores require javascript ?
Only if you want to do some dynamic stuff. For example if you want to store the rating synchronously like ajax request etc. If you want to change the content or the color of the rating stars etc. Then you require JavaScript.

How can I offer to others to show my website content in their website? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to know the method by which I can offer others to show my website content in their website by embedding it either by a script tag or iframe. I have seen some websites showing some content for example a tournament fixture and offer visitor to embed the same content in their websites by copying and pasting the script tag or an iframe.
YouTube also offers to embed videos in other websites. Thus the content may be anything like div or table or a video. So how can I do this?
I think this question is related to somewhat I am searching. But it doesn't elaborate the solution in detail. I don't know how the external script file will show the content. Note that I am using PHP as a server-side language.
So you want to let other websites embed an iframe showing some content from your website but not the entire website. What you could do (though probably not the only solution) is to take the content you want to share, say a blog post, and make that into a standalone HTML page.
So create a page with URL foobar.com/blog/post1 but it only contains the post, not your entire website layout, navbar, footer etc. (This will be the case if you are using a MVC or making a SPA website). Make sure to include necessary styles and scripts with it too.
This can then be included in an iframe: <iframe src="http://foobar.com/blog/post1"></iframe>
Another alternative is to write an API where the other websites can request your blog post (or pictures, content or whatever) as .JSON objects, possibly containing the HTML as a string.
Really there are quite a few options depending on it being static or dynamic content. For dynamic I would suggest to use an iframe containing the mini app, which gets updated data through an API, or maybe even websockets if it has to be live.
And don't forget to deal with CORS on your server.
EDIT
So you want to offer a JS file for other's to include in their code similarly to requesting a JS library from a CDN:
https://code.jquery.com/jquery-git2.js
In this case you can load a JS file from somebody's server. Similarly you offer a JS file for the other websites to include. This JS will load content from your server via a HTTP request. There are many libraries which facilitate this, try learning about JQuery Ajax(tutoriallink).
Then as #halfer suggested, you ask the website owner to have a div with a unique id, say 'your_website_name' which your JS script searches for and populates with data received from your server.
<div id="your_website_name"> </div>
Note:
Your question was very vague so don't hate on the SO community trying to help. In the comments they added ideas to spur on other users' answers, otherwise they would have posted an answer.
I think what you are actually searching for is how to populate HTML via JS, and pull data via the network as you seem to know the rest. Read up on these terms, maybe look at some JS libraries such as JQUERY, Mootools or even MVC frameworks if your "applet" is quite complex.
If you want more help, post a new and more specific question about your use-case, any code you have written so far helps too.

What would be the most ethical way to consume content from a site that is not providing an API? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I was wondering what would be the most ethical way to consume some bytes (386 precisely) of content from a given Site A, with an application (e.g. Google App Engine) in some Site B, but doing it right, no scraping intended, I really just need to check the status of a public service and they're currently not providing any API. So the markup in Site A has a JavaScript array with the info I need and being able to access that let's say once every five minutes would suffice.
Any advice will be much appreciated.
UPDATE:
First all thanks much for the feedback. Site A is basically the website of the company that currently runs our public subway network, so I'm planning to develop a tiny free Android app for anyone to have not only a map with the whole network and its stations but also updated information about the availability of the service (and those are the bytes I will eventually be consuming), etcétera.
There will be some very differents points of view, but hopefully here is some food for thought:
Ask the site owner first, if they know ahead of time they are less likely to be annoyed.
Is the content on Site A accessible on a public part of the site, e.g. without the need to log in?
If the answer to #2 is that it is public content, then I wouldn't see an issue, as scraping the site for that information is really no different then pointing your browser at the site and reading it for yourself.
Of course, the answer to #3 is dependent on how the site is monetised. If Site A provides advertistment for generating revenue for the site, then it might not be an idea to start scraping content, as you would be bypassing how the site makes money.
I think the most important thing to do, is talk to the site owner first, and determine straight from them if:
Is it ok for me to be scraping content from their site.
Do they have an API in the pipeline (simply highlighting the desire may prompt them to consider it).
Just my point of view...
Update (4 years later): The question specifically embraces the ethical side of the problem. That's why this old answer is written in this way.
Typically in such situation you contact them.
If they don't like it, then ethically you can't do it (legally is another story, depending on providing license on the site or not. what login/anonymousity or other restrictions they have for access, do you have to use test/fake data, etc...).
If they allow it, they may provide an API (might involve costs - will be up to you to determine how much the fature is worth to your app), or promise some sort of expected behavior for you, which might itself be scrapping, or whatever other option they decide.
If they allow it but not ready to help make it easier, then scraping (with its other downsides still applicable) will be right, at least "ethically".
I would not touch it save for emailing the site admin, then getting their written permission.
That being said -- if you're consuming the content yet not extracting value beyond the value
a single user gets when observing the data you need from them, it's arguable that any
TOU they have wouldn't find you in violation. If however you get noteworthy value beyond
what a single user would get from the data you need from their site -- ie., let's say you use
the data then your results end up providing value to 100x of your own site's users -- I'd say
you need express permission to do that, to sleep well at night.
All that's off however if the info is already in the public domain (and you can prove it),
or the data you need from them is under some type of 'open license' such as from GNU.
Then again, the web is nothing without links to others' content. We all capture then re-post
stuff on various forums, say -- we read an article on cnn then comment on it in an online forum,
maybe quote the article, and provide a link back to it. Just depends I guess on how flexible
and open-minded the site's admin and owner are. But really, to avoid being sued (if push
comes to shove) I'd get permission.
Use a user-agent header which identifies your service.
Check their robots.txt (and re-check it at regular intervals, e.g. daily).
Respect any Disallow in a record that matches your user agent (be liberal in interpreting the name). If there is no record for your user-agent, use the record for User-agent: *.
Respect the (non-standard) Crawl-delay, which tells you how many seconds you should wait before requesting a resource from that host again.
"no scraping intended" - You are intending to scrape. =)
The only reasonable ethics-based reasons one should not take it from their website is:
They may wish to display advertisements or important security notices to users
This may make their statistics inaccurate
In terms of hammering their site, it is probably not an issue. But if it is:
You probably wish to scrape the minimal amount necessary (e.g. make the minimal number of HTTP requests), and not hammer the server too often.
You probably do not wish to have all your apps query the website; you could have your own website query them via a cronjob. This will allow you better control in case they change their formatting, or let you throw "service currently unavailable" errors to your users, just by changing your website; it introduces another point of failure, but it's probably worth it. This way if there's a bug, people don't need to update their apps.
But the best thing you can do is to talk to the website, asking them what is best. They may have a hidden API they would allow you to use, and perhaps have allowed others to use as well.

How to use draggable sections like on iGoogle? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
Improve this question
When viewing iGoogle, each section is able to be drag-and-dropped to anywhere else on the page and then the state of the page is saved. I am curious on how this is done as I would like to provide this functionality as part of a proof of concept?
UPDATE
How do you make it so that the layout you changed to is saved for the next load? I am going to guess this is some sort of cookie?
Any up-to-date client side framework will give that kind of functionality.
jQuery
YUI
GWT
Prototype
Just to name a few...
Regarding the "saving" (persistency, if you will) of the data, this depends on the back-end of your site, but this is usually done via an asynchronous call to the server which saves the state to a DB (usually).
I hate to give a short answer on this, but there are several dozen different JavaScript libraries that provide this type of functionality, and lots of tutorials and howto guides available on google:
http://www.google.com/search?q=javascript+draggable
Some JavaScript libraries/frameworks you might want to take a look at:
jQuery
MooTools
Yahoo User Interface (YUI) library
It's amazingly simple with jQuery. Check out this blog entry on the subject.
Edit: I missed the "state of the page is saved" portion of the question when I answered. That portion will vary wildly based on how you structure your application. You need to store the state of the page somehow, and that will be user dependent. If you don't mind forcing the user to restore their preferences every time they clear their cookie cache, you could store state using a cookie.
I don't know how your application is structured so I can't make any further suggestions, but storing a cookie in jQuery is also amazingly simple. The first part of this blog entry tells you almost everything you need to know.
One method not mentioned here is that starting with ASP.NET in the 2.0 framework, Microsoft unveiled something called WebParts which enabled the building of controls which could be dragged and placed in the same way. This was supposed to be an easy method for users to create their own Web 2.0 style portals.

Categories

Resources