SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: Stuck in PHP
-
Jun 26, 2009, 12:45 #1
- Join Date
- Jun 2009
- Posts
- 18
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Stuck in PHP
Hi
I have a situation i which I have a form say x.html
that form has a text box for searching users with a keyword like software engineers
when submit is pressed it will give the list of software engineers in USA
now when the location tab in the result table is clicked I need to sort the results by location and the search keyword
the problem
when I click on the location i send the control to another php script that takes care of the location sorting but There is no way I can transfer the keyword as I cannot get a value from the first form ....
any suggestions
form (with keyword ) ->php script with keyword search -> select location > new script so sort results by location
I need the form keyword from the 1 script to use in the selection location script
kinda like monster search results when you get results of candidates you can select from the top bar by which one you want to sort by location ,city ,country ....etc
-
Jun 26, 2009, 13:55 #2
Add a parameter to your sorting links. Let's say you have a table header that you click to order the results. It will look like this:
PHP Code:<TH><?php
echo("<a href='sort_list.php?sort_by=location&keyword=");
echo(urlencode($_POST["keyword"]));
echo("'>")
?>Location</a></TH>
-
Jun 26, 2009, 15:51 #3
- Join Date
- Jun 2009
- Posts
- 18
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Apologize I am a newbie to this stuff...my value for keyword is got from the form which calls this php file which displays the table .
When I click the location heading on table it will call the sort_list.php according to above
so in the url <a sort_list.php?sort_by=location&keyword="...> what is the value of 'location'.....and what should i mention in the sort.php file
Also what does this mean echo(urlencode($_POST["keyword"])); ?
How do i extract the keyword value in the sort_list.php file ....as this file does not care abt the location value
Please explain in detail
-
Jun 26, 2009, 19:51 #4
Ok, let's start by cutting this like an onion:
echo(urlencode($_POST["keyword"]));
I guess echo() is obvious to you, so let's move on to urlencode(). It makes strings suitable to be part of URLs, encoding invalid characters into entities that look like %3E.
After you posted a form to this PHP page, %_POST will contain all the information in that form. $_POST["keyword"] will return the value of a field named "keyword," if it is available.
There's much, much more you will have to learn, so check out php.net and W3C. Good luck!
-
Jul 1, 2009, 07:47 #5
- Join Date
- Jun 2009
- Posts
- 18
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Wait a min
so when i do
<TH><?php
echo("<a href='sort_list.php?sort_by=location&keyword=");
echo(urlencode($_POST["keyword"]));
echo("'>")
?>Location</a></TH>
and it goes to the sort_list.php file how do i decode the url .....?
in the sort_list.php file I have
$result = mysql_query("SELECT *
FROM `jobseeker`
ORDER BY `location` ASC
LIMIT 0 , 30");
I would also like to add the keyword=engineer in result above
Bookmarks