<?php

include "../config.php";
include "../functions.php";
include "../private_functions.php";
if (isset($_GET['tagname'])) {
    $dbh = db_connect($MY_HOST, $MY_DB_PORT, $MY_DB, $DB_USER, $DB_PW);
    $res = search_post_by_tag($dbh, $_GET['tagname']);
    close_db_connection($dbh);
    echo json_encode($res);
} else {
    echo json_encode(array("status" => -1));
}
Exemple #2
0
<!-- 				<input style='height: 45px; padding:10px; font-size: 21px' type="text" class="form-control" name='tagname' placeholder="tagname" required autofocus> 
 -->		</div>
			<div class="col-md-2"> <button class="btn btn-lg btn-primary btn-block" type="submit">Search</button> </div>
	  </div>
	  </form>
		</div>


<?php 
$num_results = 0;
if (isset($_GET['tagname'])) {
    $tagname = $_GET['tagname'];
    if (0 === strpos($tagname, "#")) {
        $tagname = substr($tagname, 1);
    }
    $resp = search_post_by_tag($dbh, $tagname);
    if ($resp['status'] == 1) {
        $posts = $resp['posts'];
        for ($i = 0; $i < count($posts); $i++) {
            html_post($dbh, $posts[$i]);
            $num_results++;
        }
        if ($num_results == 0) {
            echo "<p>There appears to be no posts here</p>";
        }
    } else {
        echo "There was an error with your search";
    }
}
?>