web design question (php/ajax) - php

Hope this isn't a waste of your time. I'm working on a project, and it occured to me that there's a chunk of code out there, that should allow me to see how others have implemented this.
I've got a project where I'm going to have a page, with a sel box. the user will select an item from the selList, and based on the item selected, a separate section of the page (areaB) will change in terms of the content/tbls being displayed.
i then want to allow the user to go through a series of subpages in areaB, where the user goes through a submit/cancel/confirm process, where the stuff in areaB changes, with the rest of the page remaining the same...
i'm trying to figure out the best approach to implement the on both client/server side.
i could just have an ugly "if block" where i have abunch of logic, and i completely regen the page each time the user selects an action..
i could have an approach that might involve divs/frames, where i then just regen the targeted frame/div area.. is this even possible??
i could have some form of ajaxy process, which would only alter the targeted section(s) of the page...
so.. i'm trying to talk to anyone who has ideas on how to do this, or more ideally, if you know of a good code (client/server) side example of this... that i can examine. i'd really appreciate it!!
i've got a more detailed overview but didn't know if it would be cool to post it here...
thanks..
tom

If i've understood good this can be done in axaj. This is my idea you will have a where you load the current page with a form. After the submit button is pushed the values from form will be subtmited to an procesor let call it formprocesor.php. In formprocesor.php you will have a case that will check the step where you are in your submited for and will return the corect values to ajax proccessor in the main page. After values are recived, the ajax proccessor will display them in the result
Here is a little example: http://24ways.org/2005/easy-ajax-with-prototype there are more on a search on google with "ajax prototype tutorial"
Good luck!

Related

How does a user submit an article on a website?

I am working on this travel blog Trippindian.com . I want to build a page where a user can login via facebook and then write an article and submit it to us. Its just like I am posting a question on stackoverflow.
just FYI I am a noobie coder.
I want to understand the logic and functionality behind this.
Thanks
First, you need a database where you can store all these posts.
And then, you would need to create a page with a form element (HTML).
You would also need a php code that connects to the database and adds the value or values contained in the form.
That's pretty much what you need.
You could find other solutions, but I think it's the simplest one.

Best way to get data from non-admins internal to an organization in Wordpress

Here's the scenario:
I want to display a music playlist for each DJ at a radio station on my Wordpress site, but I don't want to have to enter that data in (Each song, artist, album, etc), in a specific custom post type or something like that.
I want each DJ to have access to a form where they can enter the playlist data in, and I can use that data. I was thinking of making a little webpage form that they can access, and then I query the database to get all that stuff, but I imagine that maybe there is an easier way using Wordpress.
The thing is, I don't want to give each DJ admin access to make posts with those custom fields filled in, so I'm not sure if there's a way to do that.
Maybe a page on the website that is password protected to fill out the form, and then I can use that data in a different page on the site? (Password protected so I'm only receiving data from actual DJs, not random people or bots.)
Sorry if this is an ignorant question, or if I'm unclear.
I searched a little bit, and couldn't find much.
Thanks in advance for ideas and insight!
You need to decide your method for doing this and try it out, when you run into a problem then you post here. It sounds like you know what you need. You're looking for a password protected form (which will check against a database) and pages based on a query to the database. This can be done in PHP or you might be able to find a Wordpress plugin to help you out.
Maybe start by making the PHP form. Then you could add the password protection. After you have that working you could make the PHP page that would query the information submitted. Take it one step at a time. It'll be much easier for people to help you if you're troubleshooting a specific issue rather than trying to figure out the logistics of how the whole system will work.

Auto-update Posts without refreshing

I'm currently only using PHP to take user submissions, put them in a database, and echo them out on a page using SQL to select from a table, such as comments. I need a system that will automatically update comments without refreshing the page like on YouTube. The less the user has to manually update, the better.
I want it to work pretty much exactly how YouTube and Twitter function, where it'll say "x NEW COMMENT(s)" and clicking that updates everything.
My teacher recommended a JQuery function, but I don't have any background in that language so I don't know where to begin looking.
I'm at a complete impasse. I will update this if you guys need additional information to aid in my search.
You are looking for AJAX
You will need a HTML page with jQuery/AJAX that calls another PHP page. In that PHP page you do the DB request and then ideally return the data as JSON so that your frontend part can display it to the user.
As every one says, AJAX is the way. You can find a simple blog I did on it here.

Can't post data to self because of design

i have a website that uses a number of containers (div's). In this scenario, we have three boxes down the left side and one bigger box on the right of these boxes. The bigger box on the right is the only thing that changes when a link is pressed, this is done with Javascript.
SO i have the index which is the main layout of the website and i also have the "pages" of the site, so when a link is pressed the main box (on the right) loads the new data.
On one of my pages i want to collect data and then run it through a PHP script that is in the head of the file, but when i click the button i realise it refreshes the whole page and it doesn't run the script on the page with the form.
Anyone had a problem like this, or know of something i could do to work around it?
I'm not really sure what code would be useful for helping me but if you need something just ask.
Thanks for the help
Since you are loading all your content via JS already, you could just POST the form data via AJAX to a PHP script to process, then read the output and either provide an error message or remove the form from the page and show your success message.
How to approach your AJAX call is dependant on what you've used as a basis for the rest of your JS.
Personally I like to use the JQuery library, as it makes AJAX calls (and much more) very simple.
How about you make the page design able to do it. Have the backend be able to spit out the state of the page when it posted.
Or use Ajax to post the data back and set the new state like you do already.

Recommendation for a Pagination procedure AJAX PHP

I am not sure the correct terminology for the process that I am trying to describe. I don't even know which platform is underlying the technique. If you understand my description, please give the link to the site(s) and or the keyword name of the process. I think it is done by AJAX, but I am not certain. I use php as the backend code, I just need to find a way to dynamically display the results. Please give suggestions. I forgot the name of the sites that use this, and my link history expired.
TIA
Description:
The page would have a search form and options. After the user submits, the search is initiated, and the results appear inside the dedicated result area. The page does not refresh, just the info inside the result area.
The display area will show 20 (or whatever) results (lines). There will be next, and previous buttons. If you hit next, the next set of results will display.
I am writing a code that generates 20 results for each display. There is no set number of results, so the results might have a start/first page, but do not have an end page.
Each time the user hits 'next', the program would generate/load new results. It would also store previous results, so that when a user hits 'prev', the previous results can instantly come up.
What techniques/program are theses?
Having recently handled pagination with Code Igniter (php framework), the following links might help you and anyone else out:
http://tympanus.net/jPaginate/
http://codeigniter.com/forums/viewthread/93045/
Usability is important and AJAX pagination introduces some important questions that need addressing regarding pagination, the following article will give some usability guidelines for displaying results in a table:
http://thedesignvanguard.com/crud-r-for-read
Code Igniter Prototype Framework Ajax Pagination:
http://codeigniter.com/wiki/AJAX_Pagination_with_CI_Pagination_Library/
Since we're using jQuery, we chose the following, Codeigniter jQuery framework for AJAX pagination
http://tohin.wordpress.com/2008/08/12/codeigniter-ajax-pagination/
http://tohin.wordpress.com/2008/10/07/codeigniter-ajax-pagination-exampleguideline/
It is not AJAX for sure.
Nobody uses AJAX for the pagination.
And there are about zillion pagination examples over internet
The only thing is never described in articles is how to persist search options for the other pages.
But it's simple enough: http_build_query() can help you
You need to have a GET/POST form submitted via AJAX which contains the fields in the search term and page number.
If you are going to set the page size to 20 results, page_num=4 will show results from 61-80 results.
Usually search results are GET instead of POST (Ex: See Google search results ) along with the page_number as another attribute and value.
#IVAN .. good to know that the library came helpful..
About that searching option; check the recent commit in github
http://github.com/neotohin/CodeIgniter-Ajax-pagination-Library there is an additional parameter added for searching.
I think the simple code in readme is enough for understanding the mechanism.
You could use datatables
https://datatables.net/
https://datatables.net/examples/data_sources/server_side.html
With this plugin using jquery also you could use server sided page request , you just have to handle the plugin post using Ajax.
post automatically sends row , page offset column, search criteria you just have to provide the json encode return
and the plugin automatically has library in featuring pagination, search sort number of rows per page and the table formatting.
Needed are jquery, and the plugin css and js for this to work
let me know if you understood my explanation.
thanks (=

Categories