Example #1
0
<?php

require_once 'config.php';
$session->requireLoggedIn();
require 'design_head.php';
if (!empty($_GET['del'])) {
    deleteWord($_GET['del']);
}
if (empty($_GET['lang']) || !is_numeric($_GET['lang'])) {
    echo '<h2>Show words</h2>';
    echo 'Select language first<br/><br/>';
    $list = getCategories(CATEGORY_LANGUAGE);
    foreach ($list as $row) {
        echo '<a href="' . $_SERVER['PHP_SELF'] . '?lang=' . $row['categoryId'] . '">' . $row['categoryName'] . '</a> (' . getWordCount($row['categoryId']) . ' words)<br/>';
    }
} else {
    echo '<h2>Show words</h2>';
    $langId = $_GET['lang'];
    $list = getWords($langId);
    foreach ($list as $row) {
        coreButton('Delete', $_SERVER['PHP_SELF'] . '?lang=' . $langId . '&amp;del=' . $row['id']);
        echo $row['word'] . '<br/>';
    }
}
require 'design_foot.php';
Example #2
0
function incrementWordCount($word)
{
    # Increments the wordCount for word $word
    global $debug;
    $word = strtolower($word);
    if ($debug) {
        echo "<br/>incrementWordCount() - word=" . $word . "<br/>";
    }
    $conn = connectToDb();
    $wordCount = getWordCount($word);
    $wordCount = $wordCount + 1;
    $sql = "update words set wordcount=? where word=?";
    $smt = $conn->prepare($sql);
    $smt->bind_param("is", $wordCount, $word);
    if ($smt->execute() === TRUE) {
        #$smt-> bind_result($result);
        #$smt-> fetch();
        $smt->close();
        $conn->close();
        if ($debug) {
            echo "sql execute ok <br/>";
        }
        return $wordcount;
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
        $conn->close();
        return -1;
    }
}