function html_post($dbh, $post) { $likes = get_num_likes($dbh, $post['pID']); $num_likes = $likes['count']; echo '<div id="post-' . $post['pID'] . '" class="row post"> <div class="col-md-3">' . user_link($post['username']) . '</div> <div class="col-md-9">' . htmlentities($post['title']) . '<span style="font-size:12px; color: #888; padding:5px; padding-left: 10px;">' . format_post_time($post['time']) . '</span> <span style="font-size:12px; color: #888; padding:5px; padding-left: 10px;">' . $num_likes . ' likes</span> <button class="btn btn-primary" onclick="like(\'' . $post['pID'] . '\', this);" type="button">like</button></div> <div class="col-md-9">' . htmlentities($post['content']) . '<span style="font-size:12px; color: #888; padding:5px; padding-left: 10px;"></span></div> </div>'; }
<?php include "../config.php"; include "../functions.php"; include "../private_functions.php"; if (isset($_GET['pID'])) { $dbh = db_connect($MY_HOST, $MY_DB_PORT, $MY_DB, $DB_USER, $DB_PW); $resp = get_num_likes($dbh, $_GET['pID']); close_db_connection($dbh); echo json_encode($resp); } else { echo json_encode(array("status" => -1)); }