Solution 1 :

To check if the user has performed a search, you can check if the search input form was posted:

$search = isset($_POST['search']) ? $_POST['search'] : '';

Then, you can just append the value to the URL:

$api_url = '' . $search;

Problem :

I’m using the following api – (PHP Version) to pull Images from a Website.

It works and I have it displaying 540 “badges”.

I’d like to add a search feature so you can search using the URL Parameters within the API

e.g. pulls all badges with any mention of the Word “Childline” within the description, or image name.

That way, when a user searches for keywords or descriptions, they get an output from the API.

Here is my current code:

            <div class="box">     
            <form action="" method="post" id="10">
<div align="center">
                <input style="width: 930px; height: 25px; padding: 5px; font-size: 16px; background: -webkit-linear-gradient(top, #EEEEEE , #fff); border: 1px solid #dddddd; 
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;" type="text" name="search" id="search" placeholder="Search Badges...">

<input style="display: none;" class="button" type="submit" name="submit" value="Submit">


</div> <br>

        <div class="box" align="center">

// Fetch API Url
$api_url = '';
// Look for Badges
$badges = json_decode(file_get_contents($api_url), true); 
foreach($badges['data'] as $badge){
    // Echo out badges
    echo '<div id="rounded" style="width:44px; height: 44px;"><img src="' . $badge['image'] . '" /></div>'; 



I’m just in the early stages of learning PHP and really have no idea where to go, but I’m willing to learn and would appreciate the help on this!