include "calldb.php";
if ($_POST['current_day'] == "") {
$current_day = 0;
}
if ($_POST['current_week'] == "") {
$current_week = 0;
}
if ($_POST['userid'] == "") {
$userid = "";
}
else
$userid = $_POST['userid'];
// SQL command
$sql = "SELECT * FROM words ";
if($current_day)
{
$sql .= " WHERE day = $current_day AND week = $current_week ";
}
$sql .= " ORDER BY RAND() LIMIT 5";
if (!$res = mysql_query($sql)) {
echo "SQL:".$sql."missed\n";
exit;
}
$i = 0;
while ($row = mysql_fetch_array($res)) {
// read SQL result
$wordid[$i] = $row["WordID"] ;
$english[$i] = $row["English"] ;
$japanese[$i] = $row["Japanese"] ;
$japanese[$i] = mb_convert_encoding($japanese[$i], "SJIS", "EUC-JP");
$rank[$i] = $row["Rank"] ;
$day[$i] = $row["Day"] ;
$i ++;
}
mysql_free_result($res);
mysql_close($con);
$q = rand(0, 4);
echo "Q. $english[$q] の意味は?
";
?>