I am quite new to coding, so I am open to help with critics as well. I am trying to put points on the page in my search results. I have returned the results that I need, the limit is applicable and managed to present the points control on the page correctly. However, when I select the "Next" or "Previous" page, there is no result on pages. I'm sure something is wrong by default, but I can not find it.
? Php include_once ("db_connex.php"); If (isset ($ _POST ['search'])) {$ searchq = $ _POST ['search']; $ Count_query = mysql_query ("SELECT * activated by activists where '% $ searchq%' or '% $ searchq%' fields and 'position =' 1 '"); $ Count = mysql_num_rows ($ count_query); // if the page begins to be numbered (isset ($ _ GET ['page'])) {$ page = pre_replace ("# [^ 0-9] #", "", $ _ GET ['page' ]); } And {$ page = 1; } $ PerPage = 3; $ Final page = roof ($ count / $ per page); If ($ page & lt; 1) {$ page = 1; } And if ($ page & gt; $ lastPage) {$ page = $ lastPage; } $ Limit = "LIMIT" ($ page - 1) * $ perPage ", $ PerPage"; $ Query = mysql_query ("SELECT * activated by worker where '% $ searchq%' or '% $ searchq%' such as 'Jobitel' and field status = '1 $ limit of job liability by order'); } If ($ last page! = 1) {if ($ page! = $ Lastpage) {$ next = $ page + 1; $ Pagination = '& Lt; A href = "jobsearch.php? Page = '. $ Next.'" & Gt; Next & lt; / A & gt; '; } If ($ page! = 1) {$ prev = $ page - 1; $ Pagination = '& Lt; A href = "jobsearch.php? Page = '. $ Prev.' '& Gt; Previous & lt; / a & gt;';}} while ($ line = mysql_fetch_array ($ query)) {$ jobtitle = $ row [ 'Jobitl']; $ fields = $ row [ 'field']; $ salary = $ row [ 'pay']; $ job description = Description of $ row [ 'jobs']; $ job = $ row [' Job '];; $ output. =' & Lt; div id = "searchresults" & gt; & lt; a href = "http://www.nursestation.co.uk/jobdetails.php?id= ' $ Jobid. "" & Gt; & Lt; Div id = "applybutton" & gt; Details & lt; / Div & gt; & Lt; / A & gt; & Lt; Font id = "resultstitle" & gt; '. $ Jabitil. ' & Amp; Nbsp; & Amp; Nbsp;. $ Region & Amp; Nbsp; - & amp; Nbsp & lt; / Font & gt; & Lt; Br> & Lt; / Div & gt; ';' $ Pay .. '' $ Jobdescription .. '}? & Gt; if-else the hell
($ _GET ['Page'])) {$ page = pre_replace ("# [^ 0-9] #", "", $ _ GET ['page']); } And {$ page = 1; }
can be solved this way (initially to default):
// starts indexing page $ page = 1 ; If (isset ($ _GET ['page'])) {$ page = pre_replace ("# [^ 0-9] #", "", $ _ GET ['page']); }
Or even (if you find the adventurer):
$ page = (isset ($ _ GET ['page'] )? Pre_replace ("# [^ 0-9] #", "", $ _ GET ['page']): 1);
Making a lot of IZ-E is harder later and later, so keep it simple by reducing it.
This is also common:
... while ($ row = mysql_fetch_array) in any resolution make your code smaller in the Near phase. Used to be. ($ Query)) $ $ JOBITIL = $ line ['JOBITIL']; $ Area = $ line ['field']; ...
Why specify $ Job title
to the $ line ['jubilate'];
? It does not make your code easy, it just adds more code and reads you hard. $ line ['x']
Additionally, as @OverGeneral has given you "$ search" Parameters will be ignored at all times, otherwise your entire code block ( "$ search" is not set)
Finally, when working with MySQL, With your questions, in this example, $ searchq
. The malicious encoder may look like a part of the query $ searchq
. There is a simple improvement for this:
Instead of plain:
$ count_query = mysql_query ("Select 'from active job anywhere'% $ searchq% 'or area '% $ Searchq%' and status = '1' ");
Taste it:
$ searchq = mysql_real_escape_string ($ searchq); $ Count_query = mysql_query ("SELECT * activated by activists where '% $ searchq%' or '% $ searchq%' fields and 'position =' 1 '");
not a universal solution, but starter before you dive in new technologies as a starter. This is necessary for areas like username, password etc.
Finally, replace:
if (isset ($ _POST ['search'])) {$ Searchq = $ _POST ['search'];
if (isset ($ _GET ['search'])) {$ searchq = $ _GET ['search'];
Comments
Post a Comment