Search Field choice re-directs to a certain page ...

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 544 Views - Last Post: 10 April 2019 - 02:23 PM Rate Topic: -----

#16 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2290
  • View blog
  • Posts: 6,981
  • Joined: 15-January 14

Re: Search Field choice re-directs to a certain page ...

Posted 09 April 2019 - 04:09 PM

Right now PHP prints the URL from the database for the watch page. Replace that with the URL of the search results page instead of the URL from the database, and add whatever search string you want. The name for the search field is "keyword" in your form, so the URL would look something like this:

$url = 'results.php?keyword=' . urlencode('whatever they searched for');


You can use what they actually typed in, or you can use the title for the current item from the database, or whatever you want the search string to be.
Was This Post Helpful? 0
  • +
  • -

#17 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 04-February 19

Re: Search Field choice re-directs to a certain page ...

Posted 09 April 2019 - 09:39 PM

Thanks again for your help
but, I'm not sure how/where to "replace":

$url = 'results.php?keyword=' . urlencode('whatever they searched for');


can you guide me as to which block of code, that I provided, that you are referring to, please?
Was This Post Helpful? 0
  • +
  • -

#18 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2290
  • View blog
  • Posts: 6,981
  • Joined: 15-January 14

Re: Search Field choice re-directs to a certain page ...

Posted 10 April 2019 - 09:48 AM

You print the dropdown list, and the URL, here:

		foreach ($search_result as $key => $search) {
			$search = PT_GetVideoByID($search, 0, 0, 0);
			$html .= "<div class='search-result'><a href='$search->url'>$search->title</a></div>";
		}

Was This Post Helpful? 0
  • +
  • -

#19 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 04-February 19

Re: Search Field choice re-directs to a certain page ...

Posted 10 April 2019 - 12:29 PM

Much thanks again for your reply/messages

I believe I changed "replace(ed) that with the URL of the search results page instead of the URL from the database"
and it seems to work. Does that coding look correct (proper)?

	if (!empty($search_result)) {
		$html = '';
		foreach ($search_result as $key => $search) {
			$search = PT_GetVideoByID($search, 0, 0, 0);
			                   //$html .= "<div class='search-result'><a href='$search->url'>$search->title</a></div>";
			$html .= "<div class='search-result'><a href='$search->search?keyword='>$search->title</a></div>";
		}
		$data = array('status' => 200, 'html' => $html);


Was This Post Helpful? 0
  • +
  • -

#20 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2290
  • View blog
  • Posts: 6,981
  • Joined: 15-January 14

Re: Search Field choice re-directs to a certain page ...

Posted 10 April 2019 - 01:06 PM

You changed it to use the search property instead of the url property, which is fine in terms of the syntax of the code, but I don't know if the search property exists or what it's set to. If it works, then that's fine, although you're sending a blank keyword string.
Was This Post Helpful? 0
  • +
  • -

#21 chrisjchrisj   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 04-February 19

Re: Search Field choice re-directs to a certain page ...

Posted 10 April 2019 - 01:23 PM

Thanks again for your informative reply. Much appreciated.

I don't understand how to change what I have to the "url property". if that would be better, can you please assist me with that?
Was This Post Helpful? 0
  • +
  • -

#22 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2290
  • View blog
  • Posts: 6,981
  • Joined: 15-January 14

Re: Search Field choice re-directs to a certain page ...

Posted 10 April 2019 - 02:23 PM

It already was set to the url property:

<a href='$search->url'>


You changed it to the search property:

<a href='$search->search?keyword='>


The URL in the database is probably the URL to watch the video. I don't know what the search property is or if it exists. I don't know what your PT_GetVideoByID function does other than returning an object, but I don't know what that object is.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2