function getHTTPObject() {
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
if (xmlhttp.overrideMimeType) {
xmlhttp.overrideMimeType("text/plain");
}
} catch(e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var ajaxFile = getHTTPObject();
ajaxFile.open("POST", "/file", true);
var fileData = new FormData();
fileData.append("file", getByName("open-file").files[0]);
ajaxFile.send(fileData);
function agent($postid) {
global $wpdb;
$uid = get_current_user_id();
$wpdb->get_results( "SELECT iduser FROM post_counts WHERE idpost='" . $postid . "' AND iduser='" . $uid . "'");
if ($wpdb->num_rows < 1) {
... тря-ля-ля что нужно сделать ...
$wpdb->query("INSERT INTO post_counts (idpost, iduser) VALUES('" . $uid . "','" . $postid . "')");
} else {
... тра-ля-ля уже тут были ...
}
}
1. N = 100
2. N = 50 + 50
3. N = 25 + 25 + 50
...
Вероятно простой комбинаторикой здесь не обойтись. Здесь нужна теория графов.