Exemple #1
0
        } else {
            $result['error'] = 'database_error';
        }
    }
} elseif ($dir == 'search_suggest') {
    $search_text = urldecode(filter_var(trim($_POST['search_text'])));
    $result['search_text'] = $search_text;
    $q = "SELECT * FROM pulse_pro_votes WHERE `item_name` LIKE '{$search_text}%'";
    $r = mysql_query($q);
    if (mysql_num_rows($r) > 0) {
        $row = mysql_fetch_assoc($r);
    }
    $result['suggestion'] = $row['item_name'];
} elseif ($dir == 'ajax_search') {
    $result['search_text'] = $search_text = filter_var($_POST['search_text']);
    $q = "SELECT * FROM pulse_pro_votes WHERE item_name LIKE '{$search_text}%'";
    $r = mysql_query($q);
    if ($row = mysql_fetch_assoc($r)) {
        $result['search_result']['item_name'] = $row['item_name'];
        $result['search_result']['cancelledVotes'] = cancelledVotes($row['item_name']);
        $result['search_result']['upvotes'] = $pulse->countUpvotes($row['item_name']);
        $result['search_result']['downvotes'] = $pulse->countDownvotes($row['item_name']);
        $result['search_result']['totalvotes'] = $pulse->countDownvotes($row['item_name']) + $pulse->countUpvotes($row['item_name']);
        $result['search_result']['count'] = $pulse->getCount($row['item_name']);
        $result['search_result']['percent'] = likePercent($row['item_name']);
        $result['search_result']['isClosed'] = $pulse->isClosed($row['item_name']) ? true : false;
    } else {
        $result['msg'] = 'no_result';
    }
}
echo json_encode($result);
Exemple #2
0
        	</td>
            <td class='centered'><?php 
    echo cancelledVotes($el['item_name']);
    ?>
</td>
            <td class='centered'>
			<?php 
    //prepare the title of the .weight div
    $title = likePercent($el['item_name']) . "% like it";
    ?>
			<div class="pollpercent" title="<?php 
    echo $title;
    ?>
">
				<div class='weight' data-lp="<?php 
    echo likePercent($el['item_name']);
    ?>
"></div>
			</div>
		</td>
		<td class='right action_td'>
			<?php 
    if ($pulse->isClosed($el['item_name'])) {
        ?>
			<a href='javascript://' class="action vote_status enable">Enable</a>
			<?php 
    } else {
        ?>
			<a href='javascript://' class="action vote_status disable">Disable</a>
			<?php 
    }