Exemple #1
0
<?php

include_once '../db_info.php';
session_start();
$filter = $_GET['filter'];
$gTags = grab_all_tags();
$len = strlen($filter);
/*
 *  XML STRUCTURE
 *  <suggestions>
 *      <in_filter>
 *          <tag_id></tag_id>
 *          ...
 *          <tag_id></tag_id>
 *      </in_filter>
 *      <ex_filter>
 *          <tag_id></tag_id>
 *          ...
 *          <tag_id></tag_id>
 *      </ex_filter>
 */
//XML declaration
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='utf-8'?>";
//doctype
echo "<suggestions>";
//root tag
echo "<in_filter>";
//loop through tags
foreach ($gTags as $key => $value) {
    if (substr($value, 0, $len) == $filter) {
Exemple #2
0
function grab_post($post_id)
{
    global $db;
    //Include db connection in function
    $pTags = grab_post_tags($post_id);
    //Grab the tags associated with the post using grab_post_tags()
    $gTags = grab_all_tags();
    //Grabs global tags with grab_all_tags()
    //  -Prepare query
    $select_post = $db->prepare('SELECT title, author, date, date_mod, contents FROM posts WHERE id=?');
    //  -Bind Parameters
    $select_post->bind_param('i', $post_id);
    //  -Execute
    $select_post->execute();
    //  -Bind Result
    $select_post->bind_result($title, $author, $date, $date_mod, $contents);
    //  -Fetch Results
    $select_post->fetch();
    //Create post object
    $newPost = new Post($post_id, $title, $author, $date, $date_mod, $contents, $pTags, $gTags);
    //Close query
    $select_post->close();
    return $newPost;
}