0
難道有人會告訴我我該如何做到這一點,或者如果這不可能,那麼以另一種方式展示我?如何使用數組值或類似的選擇數據,在PHP的MySQL?
我試圖得到這樣的描述:用戶輸入並切掉一些單詞,然後獲取第一個單詞並搜索數據庫中是否有另一個單詞,就像它在與該單詞相關的單詞的描述中一樣
這整個事情是有點像一本字典
$word = (isset($_POST['word']) ? $_POST['word'] : null);
$description = (isset($_POST['description']) ? $_POST['description'] :
null);
echo "<br>" . "<br>";//this is why its showing
$Slicer = array(' a ', 'A ', 'The ', ' the ', ' an ', ' this ', ' that
',
' these ', ' those ', ' my ', ' your ', ' his ', ' her ', ' its ',
' it\'s ', ' our ', ' their ', ' few ', ' little ', ' much ', ' many ',
' lot ', ' of ', ' most ', ' some ', ' any ', ' enough ', ' all ', '
both ',
' either ', ' neither ', ' each ', ' every ', ' other ', ' another ',
' Here ', ' I ', ' me ', ' mine ', ' myself ', ' i ',
' you ', ' your\'s ', ' yourself ', ' he ', ' him ', ' his ',
' himself ', ' she ', ' her\'s ', ' herself ', ' itself ',
' we ', ' us ', ' our ', ' ours ', ' ourselves ', ' yourselves ',
' they ', ' them ', ' theirs ', ' themselves ', ' no ', ' none ',
' not ', ' any ', ' few ', ' few ', ' several ', ' great ', ' deal ',
' lot ', ' lots ', ' large ', ' amount ', ' plenty ', ' more ',
' fewer ', ' fewest ', ' less ', ' least ', ' what ', 'she\'s',
'the ', ' to ', ' for ', ' something ', ' or ', ' used ',
' represent ', ' in ', ' by ', ' are ', ' often ', ' called ', 'a ',
'.');
$sliced = str_replace($Slicer,' ',$description);
echo $sliced;
echo "<br>";
$SWords = (explode(" ",$sliced));
echo "<br>";
$FirstWord = $SWords[1];
echo "<br>";
echo $FirstWord;
echo "<br>";
$test = "test";
$sql = "SELECT * FROM WordDatabase WHERE description LIKE '"
.$FirstWord."'";
我有更多的代碼和Im連接到我的數據庫和一切
謝謝你的建議和解決方案! –
「SELECT * FROM WordDatabase WHERE description LIKE'%$ FirstWord%''」 –