Returning forum data - php

I have a search forum that takes a users input and checks it against a MySQL database. Every thing works great unless I move to the second page of the search results at that point all the forum data erases. I tried to do make it work with $PHP_SELF and <a> to no avail. Code below. Thank you in advance.
$second_prev

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.

Passing Variables between PHP pages then performing a MySQL search

fairly new to PHP and webdesign.... I have a website which has a bunch of products for vehicles - all of this is stored in a database.
In order to narrow down what products are available, I want to take the user through 2-3 pages where they firstly select what categorey of product they want, then what make of car they have, then the model, then I want to run a mysql query with that information and return the answerson a page.
I already have the code to request the info from a database and then display it on the page, but The way the current website is setup, they are hard coded mysql queries (meaning the user didnt input any data to get there).
So how can I transfer variable between php pages? Page 1 (contains Categorey) - then pass to Page 2 (contains Make) then page to Page 3 (contains Model) then compile the three variavles collections, and pass them to results.php (a standard results page which Gets variables and then searches).
I know this might seem basic, but I am really stumped as to how to get it coded.
If someone can give me an a newbie explanation about how to achieve this? Thank you
You can pass PHP variables through URLs for example
Your HTML code,
<a href='yourPage.php?yourVariable=someValue'>TEST!</a>
Your PHP code,
if (isset($_GET['yourVariable'])) {
$yourVariable = $_GET['yourVariable'];
// Your code here.
}
Now using this you can create what you want with a little bit of tinkering.
Remember
You need to use $_GET because parameters are being passed using the URL and not a POST request.
Don't forget to clean all input.

Bug with Php Pagination

I have a PHP page which displays n number of records in form of table from database(till here pagination works fine). Using a search field i am triggering another query, which displays the results in 2 pages. The first page shows the result fine, but when i click on the 2nd page link, it displays the result from the initial query.
any suggestions would help me to identify the actual issue that is causing this.
Thanks!
As a was stuck with same issue earlier.
The solution is to pass searching input value along pagination parameters.
In your case pagination just take it's parameter and performs its working by excluding searching query.
So just passing searching input value(Query) you will get proper result.

ModX: Custom query only works when I update the snippet

I have a script that runs a PHP MySQL query with information gathered via a form. The query works fine but the weird thing is that it wont update the search variables if someone refreshes and enters new input into the form.
I can actually see the correct variables in the URL but they are just not being repeated in the query.
The really odd thing is if I go and edit the snippet in the ModX back end - even if its just adding a comment - save it and refresh the page it works until I try a new search again.
Would anyone know whats happening here?
Is your form snippet cached? You'll need it uncached to have it run fresh every time:
[[!snippet]]
That goes for any placeholders too:
[[!+placeholder]]

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