0
我想創建一個類的搜索框,我總是使用這個特定的代碼,沒有使用類。PHP - 搜索框不工作
但現在,即時學習如何使用類,我需要把我的舊代碼,以一個單獨的類,我想這個功能:
從代碼function verGaleria() {
$sql = "SELECT * FROM `cds`";
if(($rs=$this->bd->executarSQL($sql))){
if(isset($_GET['buscar'])){
$sql = mysql_query("SELECT * FROM `cds` where name like '%".$_GET['buscar']."%'");
}
while ($row = mysql_fetch_array($rs)) {
$imagem = $row['imagem'];
$ID = $row['ID'];
$artista = $row['artista'];
$preco = $row['preco'];
$titulo = $row['titulo'];
echo '
<style>
.teste{
text-align:center; display: inline-block; width:300px; margin: 0 0 40px 30px; float:left; color:white;
}
</style>
<div class="teste">
<h1>'.$titulo.'</h1>
<h2><img class="cd" src="CDs/'.$imagem.'" width="102" height="126" alt="'.$artista.'"/></h2>
<h3>'.$preco.'€</h3>
</div>
';
}
} else {
return false;
}
}
我:
<form method="GET" name="buscar" >
<label><a class="utilizador">Procurar</a>
<br />
<input type="text" name="buscar" id="prc" placeholder="Ex: Rock"/></label>
<input type="submit" class="submitprc" value="Pesquisar" />
</form>
問題是什麼?你是否故意離開form標籤的'action'屬性? –
@LuckySoni,它不工作:) – Atle
@Atle什麼不行?當你做什麼時會發生什麼?大聲笑 –