-4
我一直在爲學校的項目工作,我要你搜索一個字符串,它將查詢數據庫並返回所有字符串字母。爲此,我必須使用strtoupper(),如果您有所有大寫或小寫字母的字符串,它可以正常工作。如果您在搜索中輸入AAB或aab,則一切都會正常工作,並且會返回ABA和BAA這兩個字母。但是,如果您鍵入aAB,它將不會返回任何內容。 因此,它從輸入中獲取發佈數據,名爲alpha,然後它是字母化的單詞,所以如果您在ABA中鍵入,它將返回AAB,然後使其成爲大寫。
Strtoupper()PHP爲混合字符的字符串
<title>Scrabble</title>
<?php
require 'connect.inc.php';
if (isset($_POST['al'])){
$al=$_POST['al'];
$al=alpha($al);
$al=trim(strtoupper($al));
$query="SELECT * from Words WHERE alpha='$al'";
if ($query_run = mysql_query($query)){
while ($query_row = mysql_fetch_assoc($query_run)){
$alpha = $query_row['alpha'];
$ana = $query_row['word'];
echo "<strong>$ana</strong> $alpha<br>";
}
}
}
function alpha($word){
$array=array();
for($x=0;$x<strlen($word);$x++){
$char=substr($word,$x,1);
$array[$x]=$char;
}
sort($array);
$alpha=implode('',$array);
return $alpha;
}
?>
<form action='scrabble.php' method='POST'>
Enter text to anagram. Please use either all uppercase or all lowercase<input type='text' name='al'>
<input type='submit'>
</form>
他的鏈接在這裏 http://newdev.shodor.org/~amalani/newdev/scrabble.php 感謝
向我們展示你的代碼 –
請記住,MySQL的默認選擇**不區分大小寫**歸類。 (如果這是你正在使用的)。 – Halcyon
您提供的代碼不完整,並且有多個語法錯誤。向我們展示*完全*您正在使用的內容(以及所有內容......)。 – Supericy