-
Notifications
You must be signed in to change notification settings - Fork 0
/
tempSaveWord.php
41 lines (34 loc) · 1.82 KB
/
tempSaveWord.php
1
<?php $db = new SQLite3('DatabaseVocabulary.db'); $word_id = htmlspecialchars($_GET["word_id"]); if ($word_id == 0) { $db->exec('INSERT INTO word (word, usage, pronunciation, wordlist_id) VALUES ("' . $_GET["word"]. '", "' . $_GET["word"]. '", "' . $_GET["pronunciation"] . '", "' . $_GET["wordlistId"] . '")'); $word_id = $db->lastInsertRowid(); } else { $db->exec('UPDATE word SET word = "' . $_GET["word"] . '", pronunciation = "' . $_GET["pronunciation"] . '", wordlist_id = ' . $_GET["wordlistId"] . ' WHERE id = ' . $word_id); } $db->exec('DELETE FROM word_video where word_id=' . $word_id); $results = $db->query('SELECT * FROM temp_video'); while ($row = $results->fetchArray()) { $video_id = 0; $results2 = $db->query('SELECT * FROM video where movie_name="' . $row['movie_name'] . '" and file_name="' . $row['file_name'] . '"'); while ($row2 = $results2->fetchArray()) { $video_id = $row2['video_id']; } if ($video_id == 0) { $db->exec('INSERT INTO video (movie_name, file_name, youtube_id, youku_id) VALUES ("' . $row['movie_name'] . '", "' . $row['file_name'] . '", "", "");'); $video_id = $db->lastInsertRowid(); } //echo "word_id = $word_id ; video_id = $video_id<br>sentence = " . $row['sentence'] . "<br>\n"; $db->exec('INSERT INTO word_video (word_id, video_id, sentence) VALUES (' . $word_id . ', ' . $video_id . ', "' . $row['sentence'] . '");'); } $db->close(); //echo "<button type='button' style='font-size : 12pt;' onclick='location.href = \"index.php#" . htmlspecialchars($_GET["word"]) . "\";'>OK</button>\n"; //echo '<script type="text/javascript"> window.location = "index.php" </script>'; //[c red][/c] $returnObj = new stdClass(); $returnObj->wordId = $word_id; $returnObj->videoId = $video_id; $returnJSON = json_encode($returnObj); echo $returnJSON;?>