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什么不行?当你做什么时会发生什么?大声笑 –