/    Sign up×
Community /Pin to ProfileBookmark

What Is This + Sign In The Url ?

Php Folks,

Creating a pagination.
Url looks like this:
http://localhost/test/pagination_test.php

Look at these 2 buttons.

““
<button name=search value=” “>Search</button><br>
““

““
<button type=”submit” name=”search” value=”search”>Search</button>
““

Since both buttons are valid, I am testing their activity using both of them.
Here is the result.
When I click the 1st button, I am taken to a url that looks like this:
http://localhost/test/pagination_test.php?keywords=heman&search=+

I don’t want the “search=” appearing in the url. The form name is “search” (form name=”search”) and that is appearing in the url which I don’t want.
Q1A. How to fix this ?

Also, I do not want the “+” appearing in the url.
Q1B. How to fix this without deleting the form name ? And where did this “+” come from ?

When I click the 2nd button, I am taken to a url that looks like this:
http://localhost/test/pagination_test.php?keywords=heman&search=search

I don’t want the “search=” appearing in the url. The form name is “search” (form name=”search”) and that is appearing in the url which I don’t want.
Q2A. How to fix this without deleting the form name ?

Q3.
Why I get displayed no results from db tbl ? The tbl is “links” and column is “keywords” and entry is “heman”. This entry exists in row 0 in tbl. And so, the result should have been displayed.

conn.php

““
<?php

//https://phpdelusions.net/mysqli/mysqli_connect

$server = ‘localhost’;
$db_user = ‘root’;
$db_password = ”;
$db = ‘test’;

mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
$conn = mysqli_connect($server,$db_user,$db_password,$db);
mysqli_set_charset($conn,’utf8mb4′);

if(mysqli_connect_error())
{
echo “Mysqli Connection Error” . mysqli_connect_error();
}
elseif(mysqli_connect_errno())
{
echo “Mysqli Connection Error Number” . mysqli_connect_errno();
}

?>
““

error_reporting.php

““
<?php

//https://phpdelusions.net/articles/error_reporting

ini_set(‘display_errors’,’1′);
ini_set(‘display_startup_errors’,’1′);
ini_set(‘error_reporting’,’E_ALL’);//error_reporting(E_ALL);
?>
““

pagination_test.php

““
<?php
require ‘conn.php’;
require ‘error_reporting.php’;
?>

<!DOCTYPE HTML”>
<html>

<head>
<meta name=”viewport” content=”width-device=width, initial-scale=1″>
</head>
<body>

<?php

if($_SERVER[‘REQUEST_METHOD’] === ‘GET’)
{
if(ISSET($_GET[‘search’]))//THERE WILL BE MORE THAN ONE BUTTON ON THIS PAGE. HENCE THIS LINE.
{
if(ISSET($_GET[‘keywords’]))
{
$keywords = $_GET[‘keywords’];
}

$query_1 = “SELECT COUNT(id) FROM links WHERE keywords = ? OR keyphrases = ?”;
$stmt_1 = mysqli_stmt_init($conn);
if(mysqli_stmt_prepare($stmt_1,$query_1))
{
mysqli_stmt_bind_param($stmt_1,”ss”,$keywords,$keywords);
mysqli_stmt_execute($stmt_1);
$result_1 = mysqli_stmt_bind_result($stmt_1,$row_count);
mysqli_stmt_fetch($stmt_1);
}
mysqli_stmt_close($stmt_1);
mysqli_close($conn);

//PAGINATION
$page_number = $_GET[‘page’];
$result_per_page = $_GET[‘page_limit’];
$offset = (($page_number * $result_per_page) – $result_per_page); //Offset (Row Number that ‘Starts’ on page).
$previous_page = $page_number-1;
$next_page = $page_number+1;

echo “Row Start: $offset”; echo “<br>”;

$query_2 = “SELECT page_url,link_anchor_text,page_description,keyphrases,keywords FROM links WHERE keywords = ? OR keyphrases = ? ORDER by id LIMIT $offset,$limit”;
$stmt_2 = mysqli_stmt_init($conn);
if(mysqli_stmt_prepare($stmt_2,$query_2))
{
mysqli_stmt_bind_param($stmt_2,”ss”,$keywords,$keywords);
mysqli_stmt_execute($stmt_2);
$result_2 = mysqli_stmt_get_result($stmt_2);
//Grab total number of pages to paginate.
//$total_pages = ceil($result_1/$result_per_page);
$total_pages = ceil($row_count/$result_per_page);

echo “TOTAL PAGES: $total_pages<br><br>”;
if(!$result_2)
{
die(“fetching Error”);
}
while($row = mysqli_fetch_array($result_2,MYSQLI_ASSOC))
{
//Retrieve Values.
$page_url = $row[“page_url”];
$link_anchor_text = $row[“link_anchor_text”];
$page_description = $row[“page_description”];
$keyphrases= $row[“keyphrases”];
$keywords = $row[“keywords”];

echo “Page Url: $page_url<br>”;
echo “Link Anchor Text: $link_anchor_text<br>”;
echo “Page Description: $page_description<br>”;
echo “Keyphrases: $keyphrases<br>”;
echo “Keywords: $keywords<br>”;
echo “<br>”;
echo “<br>”;
}
$i = 1;
while($i<=$total_pages)
{
if($i<$total_pages)
{
echo “<a href=”pagination_test.php?page_limit=10&page=$i”>”;?><?php echo ” $i “;?></a><?php
}
elseif($i==$page_number)
{
echo “<a href=”pagination_test.php?page_limit=10&page=$i”>”;?><?php echo “<b> $i </b>”;?></a><?php
}

$i++;
}
if($page_number>$total_pages)
{
echo “?><a href=”pagination_test.php?page_limit=10&page=$previous_page”>”;?><?php echo “<b> Previous </b>”;?></a><?php
}
}
//Close Statement.
mysqli_stmt_close($stmt_2);
//Free Result.
mysqli_free_result($result_2);
//Close Connection.
mysqli_close($conn);
}
}

?>

<form method = “GET”>
<label for=”keywords”>Keywords:*</label>
<input type=”text” name=”keywords” id=”keywords” placeholder=”Input Keywords” required>
<br>
<button name=search value=” “>Search</button><br>
<button type=”submit” name=”search” value=”search”>Search</button>
<br>
<input type=”reset”>
<br>
</form>

““

Q4. When I click the “Search” button and the page reloads, the html form disappears. Why ?
Ofcourse, if I put the html form above the php code then it doesn’t disappear. But I am instructed to put the php above the html form. And so, did it.

to post a comment
PHP

13 Comments(s)

Copy linkTweet thisAlerts:
@daveyerwinAug 03.2020 — form elements don't require a name

a good practice is

Don't do this ...

<form name="some name">

you really should study

HTML Forms
Copy linkTweet thisAlerts:
@developer_webauthorAug 03.2020 — @DaveyErwin#1621695

Ok. Look at my html now:

<form action="<?php echo $_SERVER['PHP_SELF'];?>?page_limit=2&page=1" method='GET'>
<label for="keywords">Keywords:*</label>
<input type="text" name="keywords" id="keywords" placeholder="Input Keywords" required>
<br>
<button name=search value=" ">Search</button><br>
<button type="submit" name="search" value="search">Search</button>
<br>
<input type="reset">
<br>
</form>


Still no luck!

Can you answer my 4 questions in original post ?

Check latest code as amended and not original post's code.

All the issues remain which I mentioned in original post.
Copy linkTweet thisAlerts:
@developer_webauthorAug 03.2020 — Folks,

What I do not understand is this!

<form action="<?php echo $_SERVER['PHP_SELF'];?>?page_limit=2&page=1" method='GET'>

The page limit should be inserted in the url.

But when I submit the form, the urls look like this:

1st button click:

http://localhost/test/pagination_test.php?keywords=heman&search=+

2nd button clicked:

http://localhost/test/pagination_test.php?keywords=heman&search=search

Why doesn't the "page_limit" show up in the url after clicking the search buttons ?

For the "&page_limit=" to get added to the url, it seems I need to switch from form method=GET to POST. But, I was advised not to use POST! Now what !

You see, I built pagination before 9workign) but with POST. But programmers tell me, I should use GET method, plus I haven't added the min requirement in POST and so my code is buggy even if it works. That is what they said about another code. Not this one in this thread.

And so, now trying to build a simple, shorter pagination, with GET method. Ok ?

UPDATE. It seems, if I have to stick to form method GET and inject the "&page_limit=" part in the url, then I must create a user input field called "page_limit" such as this:

<input type='text' name='page_limit'>

Best to create a drop down with numbers as options.

Apart from this way, is there any other simpler way to fix this issue to use form method as GET and be able to inject the page limit in the url "&page_limit=" part.

'page Limit" means, how many results should be displayed on the page. How many matching tbl rows.
Copy linkTweet thisAlerts:
@developer_webauthorAug 03.2020 — UPDATE:

Nope! Still ain't working.

Can you see if you can spot any errors in my coding ? Clicking any of the 2 search buttons yields no matching rows from tbl.

Changes I made:

Page Limit added in url

<form action="<?php echo $_SERVER['PHP_SELF'];?>?page_limit=$page_limit&page=1" method='GET'>


Added Dropdown options in Html Form

<label for="page_limit">Results per Page</label>
<select name="page_limit" id="page_limit">
<option value=""></option>
<option value="10">10</option>
<option value="10">25</option>
<option value="10">50</option>
<option value="10">100</option>
</select>


Added $page_limit in url in pagination section:

while($i<=$total_pages)
{
if($i<$total_pages)
{
echo "<a href="pagination_test.php?page_limit=$page_limit&page=$i">";?><?php echo " $i ";?></a><?php
}
elseif($i==$page_number)
{
echo "<a href="pagination_test.php?page_limit=$page_limit&page=$i">";?><?php echo "<b> $i </b>";?></a><?php
}

$i++;
}
if($page_number>$total_pages)
{
echo "?><a href="pagination_test.php?page_limit=$page_limit&page=$previous_page">";?><?php echo "<b> Previous </b>";?></a><?php
}



Original url:

http://localhost/test/pagination_test.php

Clicking 1st search button leads to url:

http://localhost/test/pagination_test.php?keywords=heman&page_limit=10&search=+

Clicking 2nd search button leads to url:

http://localhost/test/pagination_test.php?keywords=heman&page_limit=10&search=search

Full Code:

pagination_test.php

<?php
require 'conn.php';
require 'error_reporting.php';
?>

<!DOCTYPE HTML">
<html>

<head>
<meta name="viewport" content="width-device=width, initial-scale=1">
</head>
<body>

<?php

if($_SERVER['REQUEST_METHOD'] === 'GET')
{
if(ISSET($_GET['search']))//THERE WILL BE MORE THAN ONE BUTTON ON THIS PAGE. HENCE THIS LINE.
{
if(ISSET($_GET['keywords']))
{
$keywords = $_GET['keywords'];
}

$query_1 = "SELECT COUNT(id) FROM links WHERE keywords = ? OR keyphrases = ?";
$stmt_1 = mysqli_stmt_init($conn);
if(mysqli_stmt_prepare($stmt_1,$query_1))
{
mysqli_stmt_bind_param($stmt_1,"ss",$keywords,$keywords);
mysqli_stmt_execute($stmt_1);
$result_1 = mysqli_stmt_bind_result($stmt_1,$row_count);
mysqli_stmt_fetch($stmt_1);
}
mysqli_stmt_close($stmt_1);
mysqli_close($conn);

//PAGINATION
$page = $_GET['page'];
$limit = $_GET['limit'];
$offset = (($page * $limit) - $limit); //Offset (Row Number that 'Starts' on page).
$previous_page = $page-1;
$next_page = $page+1;

echo "Row Start: $offset"; echo "<br>";

$query_2 = "SELECT page_url,link_anchor_text,page_description,keyphrases,keywords FROM links WHERE keywords = ? OR keyphrases = ? ORDER by id LIMIT $offset,$limit";
$stmt_2 = mysqli_stmt_init($conn);
if(mysqli_stmt_prepare($stmt_2,$query_2))
{
mysqli_stmt_bind_param($stmt_2,"ss",$keywords,$keywords);
mysqli_stmt_execute($stmt_2);
$result_2 = mysqli_stmt_get_result($stmt_2);
//Grab total number of pages to paginate.
//$total_pages = ceil($result_1/$limit);
$total_pages = ceil($row_count/$limit);

echo "TOTAL PAGES: $total_pages<br><br>";
if(!$result_2)
{
die("fetching Error");
}
while($row = mysqli_fetch_array($result_2,MYSQLI_ASSOC))
{
//Retrieve Values.
$page_url = $row["page_url"];
$link_anchor_text = $row["link_anchor_text"];
$page_description = $row["page_description"];
$keyphrases= $row["keyphrases"];
$keywords = $row["keywords"];

echo "Page Url: $page_url<br>";
echo "Link Anchor Text: $link_anchor_text<br>";
echo "Page Description: $page_description<br>";
echo "Keyphrases: $keyphrases<br>";
echo "Keywords: $keywords<br>";
echo "<br>";
echo "<br>";
}
$i = 1;
while($i<=$total_pages)
{
if($i<$total_pages)
{
echo "<a href="pagination_test.php?limit=$limit&page=$i">";?><?php echo " $i ";?></a><?php
}
elseif($i==$page_number)
{
echo "<a href="pagination_test.php?limit=$limit&page=$i">";?><?php echo "<b> $i </b>";?></a><?php
}

$i++;
}
if($page_number>$total_pages)
{
echo "?><a href="pagination_test.php?limit=$limit&page=$previous_page">";?><?php echo "<b> Previous </b>";?></a><?php
}
}
//Close Statement.
mysqli_stmt_close($stmt_2);
//Free Result.
mysqli_free_result($result_2);
//Close Connection.
mysqli_close($conn);
}
}

?>

<form action="<?php echo $_SERVER['PHP_SELF'];?>?page_limit=$page_limit&page=1" method='GET'>
<label for="keywords">Keywords:*</label>
<input type="text" name="keywords" id="keywords" placeholder="Input Keywords" required>
<br>
<label for="limit">Results per Page</label>
<select name="limit" id="page_limit">
<option value=""></option>
<option value="10">10</option>
<option value="10">25</option>
<option value="10">50</option>
<option value="10">100</option>
</select>
<br>
<button name=search value=" ">Search</button><br>
<button type="submit" name="search" value="search">Search</button>
<br>
<input type="reset">
<br>
</form>



Did you spot anything unusual or buggy ? Have a clue why no rows show up on the query ?

UPDATE RESULT:

The script needs the Page Number ($page) to operate. It is not included in the url.

How to include it in the url apart from this way, which i have already done:

<form action="<?php echo $_SERVER['PHP_SELF'];?>?limit=$limit&page=1" method='GET'>



//PAGINATION
$page = $_GET['page'];//Page Number
$limit = $_GET['limit']; //Results To Display on Pagination Pages
$offset = (($page * $limit) - $page_limit); //Offset (Row Number that 'Starts' on page).
$previous_page = $page-1;
$next_page = $page+1;


Clicking any of the 2 buttons lead to urls that do not have the $page (Page Number) in the url. That is the problem. Why does this happen ?

It should be added to the url for this reason:

<form action="<?php echo $_SERVER['PHP_SELF'];?>?limit=$limit&page=1" method='GET'>
Copy linkTweet thisAlerts:
@developer_webauthorAug 03.2020 — How to simplify this in short code:

if(!ISSET($_GET['page']))
{
$page = 1;
}
else
{
$page = $_GET['page'];
}

Currently the issue remains is that the $page is not shown as part of the url. Why is that ? I really must know. It has been defined. Look:


if(!ISSET($_GET['page']))
{
$page = 1;
}
else
{
$page = $_GET['page'];
}



<form action="<?php echo $_SERVER['PHP_SELF'];?>?limit=$limit&page=$page" method='GET'>
Copy linkTweet thisAlerts:
@daveyerwinAug 03.2020 — addressing the title of this thread ...

What Is This + Sign In The Url ?

HTML Form submission will

substitue the plus sign

in the place of a white space

white spaces are not allowed in url
Copy linkTweet thisAlerts:
@developer_webauthorAug 03.2020 — @DaveyErwin#1621704

How to rid it ? I never gave any white space in url.
Copy linkTweet thisAlerts:
@developer_webauthorAug 03.2020 — ``<i>
</i>&lt;form action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;?limit=$limit&amp;page=$page" method='GET'&gt;
```

So, when click any of the 2 buttons it should take to a url that has $page value as part of it's url. But it doesn't! It's missing.
1st button click leads to:
http://localhost/test/pagination_test.php?keywords=heman&limit=10&search=+

2nd button click leads to:
http://localhost/test/pagination_test.php?keywords=heman&limit=10&search=search

That is my current issue for the pagination not to work. :(
Copy linkTweet thisAlerts:
@developer_webauthorAug 03.2020 — **uPdAtE:**

I fixed a typO from:

<select name="limit" id="page_limit">


to:


<select name="limit" id="limit">


But no luck. Issue remains.
Copy linkTweet thisAlerts:
@developer_webauthorAug 03.2020 — Switched this but no luck still ...

From:

$limit = $_GET['limit'];


To:

if(!ISSET($_GET['limit']))
{
$limit = 2;
}
else
{
$limit = $_GET['limit'];
}
Copy linkTweet thisAlerts:
@developer_webauthorAug 03.2020 — @daveyErwin,

If you don't mind, test my code in your localhost and see what you come across because once this thread's code (pagination built on my own code's skeleton) is complete then I build the pagination on your skeleton here and win the race against you:

https://www.webdeveloper.com/d/390863-lets-mess-with-pagination/4

Lol!
Copy linkTweet thisAlerts:
@daveyerwinAug 03.2020 — @developer_web#1621709

please reply to my "private"

message to you

you must be logged in

to see it
Copy linkTweet thisAlerts:
@developer_webauthorAug 03.2020 — I am unable to reply to your latest PM as it only allows me to like the pm or flag it. So, using your previous PM's post and replying on that.

You didn't reply and so I thought you weren't interested in my offer nearly a mnth ago.

Anyway, it wasn't a chat bot. But I did say I can build bots. Not too complicated ones. As you can see, I am not a very good programmer.

In short, whatever you can do on your browser manually, I can try getting the bot to do it on auto in the background aswell as in the foreground.

I built a lot of bots. Compiled them to .exe. Stupidly, I did not email myself the src codes but only the .exe for backup. My laptops died and I lost the source codes of all works from mid 2011-2017 feb!

So now, I have to start all over again.

In the past, I built these bots

  • 1. Searchengine Scraper (auto keyword searches on SEs and scrapes their results).

  • 2. Backlink Checker (searches for your backlinks on google and scrapes all the results).

  • 3. DoFollow Link Checker (You feed it a list of links and it will navigate to them and check all the links on the pages to see if they are DoFollow or Not).

  • 4. Search, Find & Replace tool.

  • 5. Open Comment Blog Finder (auto keyword searches for all your KWs on google using a footprint to find WP blogs that still have their comments open). MY BEST! As it is unique in the world.

  • 6. WP Blog Auto Commenter (this one auto posts your comments on all WP blogs found using the previous bot). ONE OF MY BEST.

  • 7. Content Spinner

  • 8. Auto Navigator/browser (auto surfs links)


  • And a whole lot of others I built over 6 yrs which I now have forgotten them as I have lost their source codes.

    Which ones out of my list you like ? Shall I try building some bots and you try selling them on clickbank.com, jvzoo.com and the like ? We split 50-50. I do the building, you do the selling.

    And then, whichever bot you like, you build the web version (.php).

    It's like this ....

    I build a bot that auto checks on google to see if your links ranks changed or not. If it changes for bad or good then it alerts you by popup or email. It saves all the links who's ranks got changed. Saves the results in .csv.

    Now you can approach companies and tell them they don;t have to hire employees to manually check on google when their links get rank drops as the bot can do it daily on auto-pilot.

    If we see the bot (.exe) sells well, then next you go and build the web version (.php). Now, we no longer sell the .exe for customers to install on their PCs. Now, customers open account on our website and the web bot checks for their links rank UPs & Downs. Our website, when it gets tonnes of paid customers, then our website value goes up. When we see we can't handle the bandwidth, we just sell it. Microsoft, Google, facebook, Yahoo are in competition to buy-out new unique high traffic websites so they benefit from the bought websites' traffics. They each buy around 100 websites per year. google bought youtube for $1.6 (bn) billion, yahoo bought delicio.us for $100m (million). And so on. Since our website will be unique, it should fetch millions of customers and the big guys (google, etc.) should approach us with an offer to buy us out. If we can't get a $bn then we try atleast a few $m.

    Well, now you know why I learning php. To learn to build web versions of my bots in order to build high and unique traffic websites then bait the big guys to buy my websites out or face competition.

    You have to be unique in ideas. Then build .exe bots or .php web bots or membership websites around them and then sell them (the bots or the websites) for big money.

    Anyway, what do you have in mind ? Chat bot ?

    Bear in mind, I'm what you would call "old fashion". Middle-aged. I live by the Ten Commandments and that means I do not like adultery or fornication or anything related to it (porn, dating sites, etc.).

    There are 2 kinds of markets B2B or Business to Business and B2C or Business To Consumers.

    It's real hard selling to the consumers, unless you got really something unique that will earn them money online.

    Nowadays, my target is B2B. Like the bot and website example I gave above. That should attract businesses.

    Since 2017, I am more into learning viral traffic methods. Then come-up with my own unique viral traffic idea. Then, build bots around them. So far, haven't built any. I got tired bot building from mid 2011 to feb 2017 and so jumped into php and struggling as you can see.

    Once I finish this pagination project, I finish completing my membership site (.php). Then, I finish my searchengine site that will have it's own bot like google bot. I am not a dreamer. I know I can't defeat google.com, msn.com, yahoo.com, youtube.com, facebook.com but I watch intently the features of the big guys and always come-up with a twist of my own unique features. Then, I try building them unique features that will help people online earn money so they forget about facebook, etc. and come to their competitor (me).

    I hate google and facebook. They became big and rich overnight. Stupid college or Uni kids. Came-up with their own unique features and lured the masses into their free services and then installed spywares etc and sold the people out to commercial companies (spammers). I want to give their noses a good bleeding. I have a few unique feature ideas up my sleeves and need to build them with php. Then once I launch, the big privacy breakers should get a heart attack when they see their users coming this way because users can earn money on my platforms over their's. Hope to see their shares tumble in the stock market. That will be my day.

    Anyway, what have you in mind ? Product for B2C or B2B ?

    Want to be a simple guy or someone who teaches the big internet guys a lesson ? With you around, I can quickly learn php and get my projects running as soon as possible.

    Anyway, I'll be busy trying to figure-out what the heck is wrong with my pagination.

    Bear in mind, I'm in my mid 40's (don't disclose this). And so, I will come across to you as thick/dense in the head when it comes to learning php. Hard to learn things at this age. I forget double quick what I learn.

    Btw (by the way), have you heard of adf.ly ? They invented a unique advertising model. I am trying to build something along the line and compete with them.

    Take care!
    ×

    Success!

    Help @developer_web spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.26,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...