returning json file content

General discussions related to php

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Sat Apr 26, 2014 1:37 pm

returning json file content

Postby henriquecarv » Sat Apr 26, 2014 1:50 pm

I'm trying to create this Web Search Page where the user will type the keyword in the text field available. using a (method = 'get') the result will be displayed in the same page getting the content from a json file.

I wrote this json file by myself just for testing the page. Until now I just got errors in the result. Does someone knows what to do?

Code: Select all

<!doctype html>
      <title>Web Search Project</title>
         <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method = 'get'>
         <h1>Search Engine</h1>
            <input type='text' name='k' size='100'/>
            <input type='submit' value='Search'/>
         <hr />

            $result = array();

            foreach($jsonDecode as $person)   

json file:

Code: Select all

    "id1": {
        "description":"blah blah"
        "keywords":"Search, News",
    "id2": {
        "description":"more blah"

php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: returning json file content

Postby seandisanti » Tue Apr 29, 2014 10:25 pm

you should look at using jquery and AJAX to do calls behind the scenes. Here's a quick example and explanation from w3schools: ... t_post.asp

Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 3 guests